[issue24874] Improve pickling efficiency of itertools.cycle

2015-08-16 Thread Raymond Hettinger
Raymond Hettinger added the comment: Applied the cycle2 patch but kept the signature the same as the original reduce (using a number instead of a boolean). -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tra

[issue24874] Improve pickling efficiency of itertools.cycle

2015-08-16 Thread Roundup Robot
Roundup Robot added the comment: New changeset 17b5c8ba6875 by Raymond Hettinger in branch 'default': Issue #24874: Speed-up itertools and make it pickles more compact. https://hg.python.org/cpython/rev/17b5c8ba6875 -- nosy: +python-dev ___ Python tra

[issue24874] Improve pickling efficiency of itertools.cycle

2015-08-16 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- priority: normal -> low ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https

[issue24874] Improve pickling efficiency of itertools.cycle

2015-08-16 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : Added file: http://bugs.python.org/file40190/cycle_reduce_3.patch ___ Python tracker ___ ___ Python-bugs-list ma

[issue24874] Improve pickling efficiency of itertools.cycle

2015-08-16 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Original Raymonds reason in msg248662 is not valid. Pickling a cycle object that fully consumed its input iterable is already space-inefficient. >>> import itertools, pickle, pickletools >>> c = itertools.cycle(iter('abcde')) >>> [next(c) for i in range(8)] [

[issue24874] Improve pickling efficiency of itertools.cycle

2015-08-16 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : Added file: http://bugs.python.org/file40189/cycle_reduce_2.patch ___ Python tracker ___ ___ Python-bugs-list ma

[issue24874] Improve pickling efficiency of itertools.cycle

2015-08-15 Thread Raymond Hettinger
Raymond Hettinger added the comment: Added an updated patch that passes all tests. -- ___ Python tracker ___ ___ Python-bugs-list mail

[issue24874] Improve pickling efficiency of itertools.cycle

2015-08-15 Thread Raymond Hettinger
Changes by Raymond Hettinger : Added file: http://bugs.python.org/file40188/cycle9.diff ___ Python tracker ___ ___ Python-bugs-list mailing li

[issue24874] Improve pickling efficiency of itertools.cycle

2015-08-15 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Current cycle implementation is simple and clever, but can be optimized. The part about iterating LGTM (but looks the firstpass field can be eliminated at all). But __reduce__ doesn't look so optimal. It makes a copy of a list and makes iterating an unpickle

[issue24874] Improve pickling efficiency of itertools.cycle

2015-08-15 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- nosy: +alexandre.vassalotti, pitrou, serhiy.storchaka stage: -> patch review ___ Python tracker ___

[issue24874] Improve pickling efficiency of itertools.cycle

2015-08-15 Thread Raymond Hettinger
Raymond Hettinger added the comment: Attaching a partial patch: * More than doubles the speed of cycle() * Cuts size of __reduce__ result by about a third (on average) * Still needs work on __setstate__ for a correct restore. -- keywords: +patch Added file: http://bugs.python.org/file401

[issue24874] Improve pickling efficiency of itertools.cycle

2015-08-15 Thread Raymond Hettinger
Changes by Raymond Hettinger : Added file: http://bugs.python.org/file40185/time_cycle.py ___ Python tracker ___ ___ Python-bugs-list mailing

[issue24874] Improve pickling efficiency of itertools.cycle

2015-08-15 Thread Raymond Hettinger
Raymond Hettinger added the comment: Also, looking at the source for itertools.cycle(), it looks like the overall speed could be boosted considerably by looping over the saved list directly rather than allocating a new list iterator every time the cycle loops around. -- __

[issue24874] Improve pickling efficiency of itertools.cycle

2015-08-15 Thread Raymond Hettinger
Raymond Hettinger added the comment: 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(ite

[issue24874] Improve pickling efficiency of itertools.cycle

2015-08-15 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- Removed message: http://bugs.python.org/msg248657 ___ Python tracker ___ ___ Python-bugs-list mailin

[issue24874] Improve pickling efficiency of itertools.cycle

2015-08-15 Thread Raymond Hettinger
New submission from Raymond Hettinger: 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(i