Why 'Flat is better than nested'

Discussion in 'Python' started by Terry Reedy, Jul 31, 2012.

  1. Terry Reedy

    Terry Reedy Guest

    >>> 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
    Terry Reedy, Jul 31, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,804
    Smokey Grindel
    Dec 2, 2006
  2. Peter Bencsik
    Replies:
    2
    Views:
    822
  3. kj
    Replies:
    53
    Views:
    2,490
    alex23
    Nov 10, 2010
  4. Ian Kelly

    Re: Why 'Flat is better than nested'

    Ian Kelly, Jul 31, 2012, in forum: Python
    Replies:
    0
    Views:
    144
    Ian Kelly
    Jul 31, 2012
  5. Terry Reedy

    Re: Why 'Flat is better than nested'

    Terry Reedy, Aug 1, 2012, in forum: Python
    Replies:
    0
    Views:
    144
    Terry Reedy
    Aug 1, 2012
Loading...

Share This Page