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

Sean 'Shaleh' Perry shalehperry at attbi.com
Thu Jul 11 11:52:07 EDT 2002


On 11-Jul-2002 Mark McEahern wrote:
>> 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.
> 
> Here's one of my pet peeves:
> 
>       if x: do_one_thing()
> 
> or:
> 
>       try: foo()
>       except: pass
> 
> The problem with collapsing these single statement blocks into one line is
> that it complicates visual scans of a block of code.  It certainly doesn't
> make a hill of beans difference to the compiler.
> 

It also guarantees the next coder will have to move the code around to add
anything, even a debug print.  Which generates overly large diffs.





More information about the Python-list mailing list