[Python-ideas] Make len() usable on a generator

Mark Young marky1991 at gmail.com
Fri Oct 3 17:36:41 CEST 2014


Why do you think len is an inherently O(1) operation? Sure, on array-based
things it is, but for an arbitrary collection, the only logical assertion
is that it's O(n). (For some containers, like arrays, it might be O(1) as
well, but you can't assume that in general)​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20141003/8ac527f2/attachment-0001.html>


More information about the Python-ideas mailing list