Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Why 'Flat is better than nested' (http://www.velocityreviews.com/forums/t948891-why-flat-is-better-than-nested.html)

Terry Reedy 07-31-2012 09:04 PM

Why 'Flat is better than nested'
 
>>> 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




All times are GMT. The time now is 11:35 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57