Freeze
Freeze introduces 3 frozen collections: FDict, FSet and FList.
They are immutable, hashable, support type-hinting, and will attempt to recursively convert mutable
collections into frozen counterparts on initialization.
Motivation
While there are built-in immutable versions for list (tuple) and set (frozenset), they have some issues:
- tuple can store mutable objects so its immutability is not guaranteed.
- frozenset can't be initialized with mutable objects.
- dict doesn't have a built-in immutable version at all.
Installation
pip install frz
Usage
from freeze import FDict, FList, FSet
a_mutable_dict = {
"list": [1, 2],
"set": {3, 4},
}
a_frozen_dict = FDict(a_mutable_dict)
print(repr(a_frozen_dict)) # FDict: {'list': FList: (1, 2), 'set': FSet: {3, 4}}
How Freeze Works
Freezing a collection is achieved by following the following logic recursively:
- Immutable objects (except for collections) stay the same.
- Mapping (e.g. dict) frozen with FDict.
- Sequence (e.g. list or tuple) frozen as FLists.
- AbstractSet (e.g. set) frozen as FSets.
- If any value in the collection can't be frozen, an exception is raised.
Known Issues:
- Type hints are only accurate as long as no data conversion was performed.
Future Plans:
- support for thawing frozen collections.
- support for freezing more mutable types.
Metadata
Release files for frz 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| frz-0.0.2.tar.gz | 3.9 kB | Without provenance | Details for frz-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| frz-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for frz-0.0.2-py3-none-any.whl |
Total release size: 8.2 kB
Release files / frz-0.0.2.tar.gz
| Download URL | frz-0.0.2.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea2fd3267da39b03afbd4d5011c212a025e6a328d55b3164bca51c5edc196892
|
|
BLAKE2b-256 checksum How to use checksums |
8f39338f834eba3a7a949b8b12c0e4af7b2328fb7bc35f144f4a01f02a16f348
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.9
|
Release files / frz-0.0.2-py3-none-any.whl
| Download URL | frz-0.0.2-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6ba9e18cf99f5980bb47885bf6fbf8d14b3bb5c0fb87515318b0115b3361b9fd
|
|
BLAKE2b-256 checksum How to use checksums |
ae624895387b4bfdd645e3d2f6a449a4243c0b8f6411b06fa727298be0fd304e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.9
|
Security for frz 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.