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.6.zip
(90.3 kB
view details)
generator_tools-0.3.6.tar.gz
(87.9 kB
view details)
Built Distributions
File details
Details for the file generator_tools-0.3.6.zip
.
File metadata
- Download URL: generator_tools-0.3.6.zip
- Upload date:
- Size: 90.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2dfd4cb007996dfec296009f0fbc7e6a4d90bf84e6c2c3a83e8f6aaf88c6f6a8 |
|
MD5 | b5f3be9cada27f5ccbffd8b42094d812 |
|
BLAKE2b-256 | 31c5c2010cb7a244ad127428478c3c35fc1187eaae2fa97418c9ad9caab66380 |
File details
Details for the file generator_tools-0.3.6.tar.gz
.
File metadata
- Download URL: generator_tools-0.3.6.tar.gz
- Upload date:
- Size: 87.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdda5d37f6205eb5c6e3ee06f8d54b005169311c5d8025fcd290ff90d5356869 |
|
MD5 | e5c4db4c80c2e36b9c2ba6eafea4d477 |
|
BLAKE2b-256 | 8e477b92da7702f6cef6377c0a7584736f4ad38bb1508859c313240e723329c7 |
File details
Details for the file generator_tools-0.3.6.win32-py2.6.exe
.
File metadata
- Download URL: generator_tools-0.3.6.win32-py2.6.exe
- Upload date:
- Size: 161.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ca31dfe23f060c36e26d7457660087e107af812ec24a2980629e00d7625293b |
|
MD5 | 13adc404d91f24144334d3dd82180a71 |
|
BLAKE2b-256 | 0a51768cc64b353c9e2953ea9015a2c6da58199638cb82e23b9491324f8dc082 |
File details
Details for the file generator_tools-0.3.6.win32-py2.5.exe
.
File metadata
- Download URL: generator_tools-0.3.6.win32-py2.5.exe
- Upload date:
- Size: 161.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49d0c1fd77d5fed92fa2acd4845f2f61787dd5db735bdda634d48b20b27989e9 |
|
MD5 | 5fd298078839c851fd813591fdd7e755 |
|
BLAKE2b-256 | 02077ad63e384c123fba30157febb1c34338a6bedf038e1cf5a7351e053f9378 |