Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #26327 > unrolled thread

Why 'Flat is better than nested'

Started byTerry Reedy <tjreedy@udel.edu>
First post2012-07-31 17:04 -0400
Last post2012-07-31 17:04 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Why 'Flat is better than nested' Terry Reedy <tjreedy@udel.edu> - 2012-07-31 17:04 -0400

#26327 — Why 'Flat is better than nested'

FromTerry Reedy <tjreedy@udel.edu>
Date2012-07-31 17:04 -0400
SubjectWhy 'Flat is better than nested'
Message-ID<mailman.2795.1343768702.4697.python-list@python.org>
 >>> 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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web