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 rhettinger
Recipients rhettinger
Date 2015-08-15.21:32:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1439674346.53.0.142034370838.issue24874@psf.upfronthosting.co.za>
In-reply-to
Content
When a cycle object has fully consumed its input iterable, __reduce__ method uses the returns a space-inefficient result when space-efficient alternative is available.

# Current way of restoring a cycle object with excess info in setstate:
>>> c = cycle(iter('de'))
>>> c.__setstate__((['a', 'b', 'c', 'd', 'e'], 1))
>>> ''.join(next(c) for i in range(20)) # next 20 values
'deabcdeabcdeabcdeabc'

# The same result can be achieved with less information: 
>>> c = cycle(iter('de'))
>>> c.__setstate__((['a', 'b', 'c'], 0))
>>> ''.join(next(c) for i in range(20)) # next 20 values
'deabcdeabcdeabcdeabc'
History
Date User Action Args
2015-08-15 21:32:26rhettingersetrecipients: + rhettinger
2015-08-15 21:32:26rhettingersetmessageid: <1439674346.53.0.142034370838.issue24874@psf.upfronthosting.co.za>
2015-08-15 21:32:26rhettingerlinkissue24874 messages
2015-08-15 21:32:26rhettingercreate