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.5.zip
(90.2 kB
view details)
generator_tools-0.3.5.tar.gz
(87.8 kB
view details)
Built Distributions
File details
Details for the file generator_tools-0.3.5.zip
.
File metadata
- Download URL: generator_tools-0.3.5.zip
- Upload date:
- Size: 90.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ad073ae401b3a5afc9891c6163f15da9795dc05f974f86a51142dbacaba6ecc |
|
MD5 | 24c0c06aa7ce7ba6220b12a1f8c1a918 |
|
BLAKE2b-256 | b5a70382c822fabf73e28d07d329bf131fe6bd7eb1f6a42115371e5f47e10f23 |
File details
Details for the file generator_tools-0.3.5.tar.gz
.
File metadata
- Download URL: generator_tools-0.3.5.tar.gz
- Upload date:
- Size: 87.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd296e9a2ca1ab8f1a02ac8cd24d54349453db1b57a915b02f8e9ce5ca2720b5 |
|
MD5 | 5df9959b096fa418d3bb86464ed0673e |
|
BLAKE2b-256 | 16c374b384735986ee5031cb9ccea0eac5ae45b5216a56828c27000f265de3a7 |
File details
Details for the file generator_tools-0.3.5.win32-py2.6.exe
.
File metadata
- Download URL: generator_tools-0.3.5.win32-py2.6.exe
- Upload date:
- Size: 161.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51181a34f7d374513c4eb771eeb16dee33cea7be52b8f25b9a474f9b8afa66c0 |
|
MD5 | b5e00f800f043581bc4877789eeb674d |
|
BLAKE2b-256 | 3269b6640ac7a00904dbc840b0a17bf89adc431566297cf0b760e406934f3894 |
File details
Details for the file generator_tools-0.3.5.win32-py2.5.exe
.
File metadata
- Download URL: generator_tools-0.3.5.win32-py2.5.exe
- Upload date:
- Size: 161.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 061f9d7751697b6466207f4bf80969dda9ef5718be7bbf6f72207300b424b9c3 |
|
MD5 | 28f840c213f6427422c03cb0191572eb |
|
BLAKE2b-256 | 25817f754cf17add37423bbb7e894729ff1218b29a40bb4682e86e865c6daaf9 |