This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bugale bugale
Recipients bugale bugale
Date 2017-11-29.23:00:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1511996453.35.0.213398074469.issue32172@psf.upfronthosting.co.za>
In-reply-to
Content
I have noticed that there is no convenient way in python to get the number of items in a generator.

For example:
  my_iterable = iter(range(1000))
  len(my_iterable) # Would not work

Of course, something like this would ruin the generator, and it will no longer be usable, but in some use cases one would like to know only the count of something.

It is possible to do it today using this line:
  sum(1 for x in my_iterable)

but it seems odd to me that there is no function like:
  itertools.count_iterable(my_iterable)
that does exactly this
History
Date User Action Args
2017-11-29 23:00:53bugale bugalesetrecipients: + bugale bugale
2017-11-29 23:00:53bugale bugalesetmessageid: <1511996453.35.0.213398074469.issue32172@psf.upfronthosting.co.za>
2017-11-29 23:00:53bugale bugalelinkissue32172 messages
2017-11-29 23:00:53bugale bugalecreate