| Store | Cart

Q: What does "Sparse is better than dense" mean? (Python Zen)

From: Peter Hansen <pet...@engcorp.com>
Thu, 11 Jul 2002 23:31:07 -0400
jepler at unpythonic.net wrote:
> > On Thu, Jul 11, 2002 at 04:30:59PM -0700, Andrae Muys wrote:> > Well seeing as we are discussing Python Zen, the one I don't currently> > understand is "Flat is better than Nested".  I had always thought the> > Nested is>     A>         B>             C>                 D> > flat is>     A>         B>         C>         D> > Python has lots of namespaces, but they're relatively flat.  Usually,> module->class->function or module->function, but with nested_scopes> sometimes an additional level of function is seen.> > That's my take on it ...

If that's true (and it sounds good to me) then one might interpret
the advice as "don't nest for the sake of nesting; nest only to 
manage complexity".

It is not necessary to nest to manage three items.  It might be
necessary to nest a little more to manage twenty or thirty.
Several hundred or thousand need a little more (i.e. the standard
library, which does have a few levels of nesting, such as package
xml).

?

-Peter

Recent Messages in this Thread
Miki Tebeka Jul 11, 2002 11:28 am
Peter Hansen Jul 11, 2002 12:24 pm
Mark McEahern Jul 11, 2002 01:07 pm
Aahz Jul 11, 2002 06:35 pm
Mike C. Fletcher Jul 11, 2002 08:23 pm
Andrae Muys Jul 11, 2002 11:30 pm
jep...@unpythonic.net Jul 11, 2002 11:45 pm
Peter Hansen Jul 12, 2002 03:31 am
Ian Bicking Jul 12, 2002 08:00 am
Tim Peters Jul 12, 2002 08:22 am
Bernhard Herzog Jul 12, 2002 07:09 pm
Peter Hansen Jul 12, 2002 08:27 am
Messages in this thread

Previous post: Recomendations on Books
Next post: Hierarchical Editor