You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

objfreeze

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

objfreeze

Function to convert data into freezed (immutable) version

0.1.0b0
pipPyPI
Maintainers
1

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/

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts