generator expressions: performance anomaly?
Raymond Hettinger
vze4rx4y at verizon.net
Mon Jan 17 07:56:39 EST 2005
[Delaney, Timothy C]
> Nick's other suggestion - that genexps propagate __len__ - might
> still be interesting. Of course, it would only be applicable for
> unconditional genexps(i.e. no if clause).
Length transparency for iterators is not as general as one would expect. I once
spent a good deal of effort exploring where it made sense, and I was surprised
to find that it only rarely works out. Length transparency is an unexpectedly
thorny subject with many dead-ends which precludes a fully general solution such
as that proposed by Nick.
For a recap of my research, see the docstring for Lib/test/test_iterlen.py .
Raymond Hettinger
More information about the Python-list
mailing list