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

Tim Peters tim.one at comcast.net
Fri Jul 12 04:22:31 EDT 2002


[Miki Tebeka]
> Although it's in the Humor section I take the Python Zen
> (http://www.python.org/doc/Humor.html#zen) quite seriously.
>
> However I can understand what does “Sparse is better than
> dense” means.
>
> Any Ideas (Tim?)

The value of an aphorism is in provoking you to ponder.  So long as you
suspect there's something of value in it that you don't yet understand, it's
doing its job.  As soon as someone thinks they understand it, and then just
repeats it (whether to endorse or ridicule doesn't much matter) in lieu of
contemplation, its usefulness is exhausted.  I suspect that's why God always
arranges to get himself killed whenever he takes on human form <wink>.

I've read that if you confine too many rats in too small a living space,
they become sociopathic.  That's density for you.  I've seen no reason to
suspect that code, concepts, data structures, interfaces, programmers or
managers have an advantage over rats in this respect.  Give yourself some
room to breathe and stretch:  couple interfaces loosely, let a subsystem
deal with a little rather than a lot, leave a little whitespace for flowers
to grow between tokens, fail soft on feathers instead of hard on rocks,
don't do two things at a time until you're pretty sure you can do one, a
function with 14 arguments-- or a module with 14 classes --is a bad idea,
don't fall for the idea that between any two abstractions you always need to
compromise on a third.  Etc.

In other words, sparse is better than dense.  Except when it comes to chip
design, where sparseness plain sucks <wink>.

pythons-swallow-rats-one-at-a-time-ly y'rs  - tim






More information about the Python-list mailing list