Algorithmic complexity of len (list)?

Leif K-Brooks eurleif at ecritters.biz
Tue Jul 6 18:45:45 EDT 2004


Roy Smith wrote:
> Iterators sort of look like lists, but I can't get their length quickly 
> (or even idempotently, it would appear).

You can if that particular iterator happens to have an __len__ method. I 
would assume that the iterator protocol doesn't require one because that 
would make infinite iterators impossible.



More information about the Python-list mailing list