[issue9547] iterator length

2010-08-09 Thread Alexandru Moșoi
New submission from Alexandru Moșoi alexan...@mosoi.ro: 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

[issue9547] iterator length

2010-08-09 Thread Benjamin Peterson
Benjamin Peterson benja...@python.org added the comment: Please post to python-ideas first. -- nosy: +benjamin.peterson resolution: - rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9547

[issue9547] iterator length

2010-08-09 Thread Raymond Hettinger
Raymond Hettinger rhettin...@users.sourceforge.net 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