A bit weird dictionary behavior

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Tue Sep 23 04:14:12 CEST 2008

Steven D'Aprano:

>For many iterables, the amount of memory is not excessive and the increase in readability of len() is to be preferred over the side-effect of sum(1 for...).<

With side-effects do you mean the possibility of exhausting a lazy

The readability difference is little, and it's way safer because it
works well enough with very long iterables too, so leniter(..) is
better than len(list(...)).


More information about the Python-list mailing list