Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Why 'Flat is better than nested'

Reply
Thread Tools

Why 'Flat is better than nested'

 
 
Terry Reedy
Guest
Posts: n/a
 
      07-31-2012
>>> import this

prints 'The Zen of Python', a poem by Tim Peters that consists of python
proverbs such as "Flat is better than nested." (Others things being
equal) why? Because it is a restatement of the principle of parsimony,
of not multiplying entities without necessity.

Suppose we have a unstructured collection of N items. Organizer comes
along and says 'Let there be structure. Let us organize the items as
leaf nodes in a hierarchical tree' (which is equivalent to nesting). To
do so, we can add as many as N-1 new non-leaf nodes and as many as
(about) 2*N - log2(N) parent child relationships. In other words, nearly
quadruple the number of entities to learn, discuss, and remember. Well,
there had better be a good necessity to do so .

And, of course, once new entities *are* conjured up, it is hard to get
rid of them.

--
Terry Jan Reedy


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is a blank at the end of a C file a better style than a newline atthe end of the file or is it better to place none? Jimmy C Programming 3 09-09-2011 10:36 PM
GL2 better than the XLs? Consumer grade HDs better than pro-sumer Mini DVs? dh@. DVD Video 1 08-28-2008 07:20 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Is splint really better than lint? Is there a better tool than splint? Peter Bencsik C Programming 2 09-21-2006 10:02 PM
Build a Better Blair (like Build a Better Bush, only better) Kenny Computer Support 0 05-06-2005 04:50 AM



Advertisments