Skip to main content

Extended pickling support for Python object

Project description

Repickle

Repickle makes it possible to serialize Python constructs not supported by the default pickle module from the Python standard library. Repickle just extends cloudpickle and add support for load and dump to files.

Installation

The latest release of repickle is available from pypi:

pip install repickle

Examples

Pickling a lambda expression:

>>> import repickle
>>> squared = lambda x: x ** 2
>>> repickle.dump_to_file(squared, "pickled_lambda.pkl")

>>> new_squared = repickle.load_from_file("pickled_lambda.pkl")
>>> new_squared(2)
4

Pickling a function interactively defined in a Python shell session (in the __main__ module):

>>> CONSTANT = 42
>>> def my_function(data: int) -> int:
...     return data + CONSTANT
...
>>> import repickle
>>> repickle.dump_to_file(my_function, "pickled_lambda.pkl")
>>> depickled_function = repickle.load_from_file("pickled_lambda.pkl")
>>> depickled_function(43)
85

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

repickle-0.1.0.tar.gz (22.3 kB view hashes)

Uploaded Source

Built Distribution

repickle-0.1.0-py3-none-any.whl (24.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page