Skip to content

Latest commit

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

cloudpickle-generators

cloudpickle support for generators, including partially consumed generators.

Usage

To use cloudpickle-generators, you must simply call register. After calling register, you may use cloudpickle like normal.

>>>importcloudpickle>>>importcloudpickle_generators# register the generator support>>>cloudpickle_generators.register()
# define a simple generator function that has both intermediate state (the# loop) and arguments>>>deff(a, b):
... forninrange(a):
... yieldb+b[-1] *n>>>gen=f(4, 'ay')
# advance the generator half way though before serializing>>>next(gen)
ay>>>next(gen)
ayy# do a serialization round trip>>>new_gen=cloudpickle.loads(cloudpickle.dumps(gen))
>>>new_genisgenFalse# advance the newly created generator instance>>>next(new_gen)
ayyy>>>next(new_gen)
ayyyy>>>next(new_gen)
Traceback (mostrecentcalllast):
...
StopIteration# the old instance is unaffected by the new one!>>>next(gen)
ayyy>>>next(gen)
ayyyy>>>next(gen)
Traceback (mostrecentcalllast):
...
StopIteration

About

cloudpickle support for generators, including partially consumed generators.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages