Sorry for the duplicate message. I realized two seconds after I sent it, that I only replied to you and not the group.
I didn't see the `consume` recipe until after I posted, or I probably would've mentioned it. What I want would have to be done in C, because `it_index` (as `listiterobject` and `unicodeiterobject` call it, not sure about the other iterators I mentioned) isn't exposed in Python-land, with the exception of the `__setstate__` workaround I mentioned before. Slicing large lists/strings/bytes/tuples is both memory and time inefficient. I don't think that `__setstate__` would even work with more general iterators, that's not what I was trying to say. `itertools.advance` (or maybe it should be called `itertools.consume` for consistency with the recipe) should use whatever is the most efficient way to advance the iterator without causing issues. Only iterators that are explicitly created tied to sequences that support random access would be able to efficiently jump forward; others would just call `next` repeatedly. `list_iterator` / `listiterobject` for example doesn't have to worry about losing any side-effects by jumping ahead. Does that answer your questions/concerns? _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/MP6FLPA2MTGQDYXXB6IEU6R272CXTRAQ/ Code of Conduct: http://python.org/psf/codeofconduct/