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 serhiy.storchaka
Recipients MSeifert, kristjan.jonsson, rhettinger, serhiy.storchaka
Date 2017-03-31.15:43:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1490975025.22.0.636479345073.issue29897@psf.upfronthosting.co.za>
In-reply-to
Content
This issue is related to the behavior of other composite iterators.

>>> from copy import copy
>>> it = map(ord, 'abc')
>>> list(copy(it))
[97, 98, 99]
>>> list(copy(it))
[]
>>> it = filter(None, 'abc')
>>> list(copy(it))
['a', 'b', 'c']
>>> list(copy(it))
[]

The copy is too shallow. If you consume an item from one copy, it is disappeared for the original.

Compare with the behavior of iterators of builtin sequences:

>>> it = iter('abc')
>>> list(copy(it))
['a', 'b', 'c']
>>> list(copy(it))
['a', 'b', 'c']
>>> it = iter(list('abc'))
>>> list(copy(it))
['a', 'b', 'c']
>>> list(copy(it))
['a', 'b', 'c']
History
Date User Action Args
2017-03-31 15:43:45serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, kristjan.jonsson, MSeifert
2017-03-31 15:43:45serhiy.storchakasetmessageid: <1490975025.22.0.636479345073.issue29897@psf.upfronthosting.co.za>
2017-03-31 15:43:45serhiy.storchakalinkissue29897 messages
2017-03-31 15:43:45serhiy.storchakacreate