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 MSeifert
Recipients MSeifert
Date 2017-03-24.19:14:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1490382866.15.0.806348806156.issue29897@psf.upfronthosting.co.za>
In-reply-to
Content
When using `copy.copy` to copy an `itertools.chain` instance the results can be weird. For example

>>> from itertools import chain
>>> from copy import copy
>>> a = chain([1,2,3], [4,5,6])
>>> b = copy(a)
>>> next(a)  # looks okay
1
>>> next(b)  # jumps to the second iterable, not okay?
4
>>> tuple(a)
(2, 3)
>>> tuple(b)
(5, 6)

I don't really want to "copy.copy" such an iterator (I would either use `a, b = itertools.tee(a, 2)` or `b = a` depending on the use-case). This just came up because I investigated how pythons iterators behave when copied, deepcopied or pickled because I want to make the iterators in my extension module behave similarly.
History
Date User Action Args
2017-03-24 19:14:26MSeifertsetrecipients: + MSeifert
2017-03-24 19:14:26MSeifertsetmessageid: <1490382866.15.0.806348806156.issue29897@psf.upfronthosting.co.za>
2017-03-24 19:14:26MSeifertlinkissue29897 messages
2017-03-24 19:14:26MSeifertcreate