[issue9547] iterator length

2010-08-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: This has been rejected before. The core issue is that it is not a very useful operation because it consumes the iterator. Also, this isn't an operation worth optimizing because most iterators that do something interesting are already slower than a gene

[issue9547] iterator length

2010-08-09 Thread Benjamin Peterson
Benjamin Peterson added the comment: Please post to python-ideas first. -- nosy: +benjamin.peterson resolution: -> rejected status: open -> closed ___ Python tracker ___ ___

[issue9547] iterator length

2010-08-09 Thread Alexandru Moșoi
New submission from Alexandru Moșoi : Sometimes it's useful to get the number of elements yield by an iterator. For example (if ilen is the name of the function): def pi(n): return ilen(for e in xrange(n) if isprime(e)) def count_pred(pred, iterator): return ilen(itertools.ifilter(pred, it