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.3.4.zip
(89.9 kB
view hashes)
generator_tools-0.3.4.tgz
(87.8 kB
view hashes)
Built Distributions
generator_tools-0.3.4.win32-py2.6.exe
(158.3 kB
view hashes)
generator_tools-0.3.4.win32-py2.5.exe
(158.3 kB
view hashes)
Close
Hashes for generator_tools-0.3.4.win32-py2.6.exe
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42183b0b1bfe541af988f4395a9f4cc20ea262a13578216c4a6b30224274215a |
|
MD5 | 58f2753f714e057d9ebd9dee83d504b8 |
|
BLAKE2b-256 | ef03893f7347a58dbebc3c0f010f88926116b663e450cd9fee407f101809a45c |
Close
Hashes for generator_tools-0.3.4.win32-py2.5.exe
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fa8b1f1b03a8ff31318cb278a5fc6a2f38bac4d38a9c2b6af27b8b24b900c32 |
|
MD5 | 7ac408b2047f0c33c5e8839929dc4f3c |
|
BLAKE2b-256 | 82007ec93c01a460b85dae93410ce93f5c0e8b6857f98d59e34b38246dd73e75 |