Skip to main content

Function to convert data into freezed (immutable) version

Project description

Short description

Function converts recursively an object of standard (im-)mutable types into strictly immutable ones.

Long description

In Python sometimes it is useful to have a “static” struct to be shared across functions and classes and to guarantee it can not be changed accidentally by some code.

In addition to standard immutable simple types (like int, str etc.), there are two complex types: frozenset and tuple. Unfortunately years ago (2012-02) there was PEP-0416[1] where a frozendict was rejected as hard to be implemented.

Unlike other wrappers implementation here works similar to a copy.deepcopy function which immediately copies mutable objects into immutable analogues instead of wrapping them at access time. Therefore if a code passes already immutable object, there is almost no overhead, but the code do not need to pay attention whether to deepcopy of incoming (or outgoing) data or not.

[1] https://www.python.org/dev/peps/pep-0416/

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

objfreeze-0.1.0b0.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distributions

objfreeze-0.1.0b0-py3.6.egg (6.3 kB view hashes)

Uploaded Source

objfreeze-0.1.0b0-py3-none-any.whl (4.9 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