Bob Ippolito (@etrepum) on Haskell, Python, Erlang, JavaScript, etc.
«

pickle those iterators

»

I made a small patch to the Stackless 2.3 branch today: iterator pickling. It now pickles/unpickles all of the private iterator types (that I know of) in Python's builtins: dictionary-iterator, listiterator, rangeiterator, tupleiterator. I'm sure it will be in CVS pretty soon.

Python 2.3.3 Stackless 3.0 040119 (#5, Jan 25 2004, 11:26:07)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pickle import loads, dumps
>>> a = iter(range(10))
>>> a
<stackless.listiterator object at 0x3d0d50>>>> a.next()
0
>>> a.next()
1
>>> b = loads(dumps(a))
>>> a.next()
2
>>> b.next()
2