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 details)
generator_tools-0.3.4.tgz
(87.8 kB
view details)
Built Distributions
File details
Details for the file generator_tools-0.3.4.zip
.
File metadata
- Download URL: generator_tools-0.3.4.zip
- Upload date:
- Size: 89.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b55f055fe123b3641aa4cc2b175f62228429843c84edd72328c803b1ac5a93a |
|
MD5 | 31c7e4213011d0131a1657c865c55802 |
|
BLAKE2b-256 | 3e71429d956676839387c55b65694a37339c166180f066216a69fc7c0946c91f |
File details
Details for the file generator_tools-0.3.4.tgz
.
File metadata
- Download URL: generator_tools-0.3.4.tgz
- Upload date:
- Size: 87.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a311277d2284c679263bc4c520e511f9ebcb4253d7aad671a6ae0382b9e2c70 |
|
MD5 | 4a9a7adff93b0234417dce843f8f905c |
|
BLAKE2b-256 | 4922e42bc264156731aeeee1016d4f0c0d18ad2d59e13cc5583d4f2f4d46ea39 |
File details
Details for the file generator_tools-0.3.4.win32-py2.6.exe
.
File metadata
- Download URL: generator_tools-0.3.4.win32-py2.6.exe
- Upload date:
- Size: 158.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42183b0b1bfe541af988f4395a9f4cc20ea262a13578216c4a6b30224274215a |
|
MD5 | 58f2753f714e057d9ebd9dee83d504b8 |
|
BLAKE2b-256 | ef03893f7347a58dbebc3c0f010f88926116b663e450cd9fee407f101809a45c |
File details
Details for the file generator_tools-0.3.4.win32-py2.5.exe
.
File metadata
- Download URL: generator_tools-0.3.4.win32-py2.5.exe
- Upload date:
- Size: 158.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fa8b1f1b03a8ff31318cb278a5fc6a2f38bac4d38a9c2b6af27b8b24b900c32 |
|
MD5 | 7ac408b2047f0c33c5e8839929dc4f3c |
|
BLAKE2b-256 | 82007ec93c01a460b85dae93410ce93f5c0e8b6857f98d59e34b38246dd73e75 |