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.3-py2.5.zip
(86.8 kB
view details)
generator_tools-0.3.3-py2.5.tgz
(84.1 kB
view details)
Built Distribution
File details
Details for the file generator_tools-0.3.3-py2.5.zip
.
File metadata
- Download URL: generator_tools-0.3.3-py2.5.zip
- Upload date:
- Size: 86.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5eef12127e0192981c583761b6cc2ce0ec41c7b9099363a5e68b4f531aee878 |
|
MD5 | d0f1ae88facc594306ad24f0090fb7c9 |
|
BLAKE2b-256 | 329fe04dbb88f9fa8e3f865c3492b3e409fe0fbebff7b9bed75155c4c6568743 |
File details
Details for the file generator_tools-0.3.3-py2.5.tgz
.
File metadata
- Download URL: generator_tools-0.3.3-py2.5.tgz
- Upload date:
- Size: 84.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d3074f3d834b895aaf48f07020504b699380fe4e5bc6cdd23f5c0d684a927ff |
|
MD5 | a692fe930dbb60fe39b48fd30364f8c4 |
|
BLAKE2b-256 | 9afe5e3e7e46ddcb932cc59edef7b304ba320a878774e862a387b8acdd83b8af |
File details
Details for the file generator_tools-0.3.3.win32-py2.5.exe
.
File metadata
- Download URL: generator_tools-0.3.3.win32-py2.5.exe
- Upload date:
- Size: 146.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f1f908f965d5ea871b1429d0be758ad9ae4abb3a28ef70afc0d409d65c6fb1c |
|
MD5 | 69248946b4f4c3ab333f7f253db3eff6 |
|
BLAKE2b-256 | f35a479f02568a225adf1578e19245176c3e6d3bbad1784c0156e5e89e03459b |