generator_tools enable copying and pickling generators
Project description
The generator tools package enables copying and pickling running generators in
CPython ( you don't need Stackless Python ).
Usage
-----
from generator_tools.copygenerators import*
from generator_tools.picklegenerators import*
def f(start):
i = start
while i<start+10:
yield i
i+=1
>>> f_gen = f(5)
>>> f_gen.next() # or next(f_gen) in Python 3.0
5
>>> f_gen.next()
6
>>> g_gen = copy_generator(f_gen)
>>> h_gen = copy_generator(f_gen)
>>> g_gen.next()
7
>>> h_gen.next()
7
>>> pickler = GeneratorPickler("test.pkl")
>>> pickler.pickle_generator(g_gen)
>>> k_gen = pickler.unpickle_generator()
>>> list(g_gen) == list(k_gen)
True
CPython ( you don't need Stackless Python ).
Usage
-----
from generator_tools.copygenerators import*
from generator_tools.picklegenerators import*
def f(start):
i = start
while i<start+10:
yield i
i+=1
>>> f_gen = f(5)
>>> f_gen.next() # or next(f_gen) in Python 3.0
5
>>> f_gen.next()
6
>>> g_gen = copy_generator(f_gen)
>>> h_gen = copy_generator(f_gen)
>>> g_gen.next()
7
>>> h_gen.next()
7
>>> pickler = GeneratorPickler("test.pkl")
>>> pickler.pickle_generator(g_gen)
>>> k_gen = pickler.unpickle_generator()
>>> list(g_gen) == list(k_gen)
True
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
generator_tools-0.1-py3.0.zip
(83.5 kB
view hashes)
generator_tools-0.1-py3.0.tgz
(81.3 kB
view hashes)
generator_tools-0.1-py2.5.zip
(80.8 kB
view hashes)
generator_tools-0.1-py2.5.tgz
(78.4 kB
view hashes)
Built Distribution
generator_tools-0.1.win32-py2.5.exe
(141.2 kB
view hashes)
Close
Hashes for generator_tools-0.1.win32-py2.5.exe
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25d3427f70d06cb491fad9df6f153bc2ac6c54648472d5331b9d2f04a14f7723 |
|
MD5 | 5b85fbd2d02c072cc0379670558cfe4b |
|
BLAKE2b-256 | 676ed03552f0f6534afc528916a17c9200ef3d67eacfdf9a7ae1ffd7c26226a4 |