[Python-ideas] An ABC representing "Iterable, Sized, Container"
rosuav at gmail.com
Sat Jul 23 20:54:42 EDT 2016
On Sun, Jul 24, 2016 at 10:15 AM, Guido van Rossum <gvanrossum at gmail.com> wrote:
> Does it work? For what categories of iterators? Surely not for streams...
I tried it with list and set iterators and it worked fine. With a
generator, it threw an exception (though not something tidy like
UncopyableObjectException - it complained about calling
object.__new__(generator) instead of generator.__new__). Presumably
it'll fail, one way or another, with non-duplicable objects (eg an
open file, which is its own iterator, simply raises TypeError "cannot
serialize"); those are non-restartable, non-bookmarkable, non-forkable
iterators (take your pick of terminology).
More information about the Python-ideas