frozendict-secure-x 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- frozendict/___init___.py +3 -0
- frozendict/_errors.py +8 -0
- frozendict/_hashing.py +8 -0
- frozendict/core.py +46 -0
- frozendict_secure_x-1.0.0.dist-info/METADATA +32 -0
- frozendict_secure_x-1.0.0.dist-info/RECORD +9 -0
- frozendict_secure_x-1.0.0.dist-info/WHEEL +5 -0
- frozendict_secure_x-1.0.0.dist-info/licenses/LICENSE +3 -0
- frozendict_secure_x-1.0.0.dist-info/top_level.txt +1 -0
frozendict/___init___.py
ADDED
frozendict/_errors.py
ADDED
frozendict/_hashing.py
ADDED
frozendict/core.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""
|
|
2
|
+
frozendict_secure.core
|
|
3
|
+
|
|
4
|
+
Author: sastha prasanth ramakrishnan (https://github.com/sastha prasanth ramakrishnan)
|
|
5
|
+
License: MIT
|
|
6
|
+
|
|
7
|
+
WARNING:
|
|
8
|
+
Removing this header violates the MIT License.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from ._hashing import compute_hash
|
|
12
|
+
from ._errors import ImmutableError
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class frozendict(dict):
|
|
16
|
+
__slots__ = ("_hash",)
|
|
17
|
+
|
|
18
|
+
def __init__(self, *args, **kwargs):
|
|
19
|
+
super().__init__(*args, **kwargs)
|
|
20
|
+
self._hash = None
|
|
21
|
+
|
|
22
|
+
# ❌ Block all mutations
|
|
23
|
+
def _immutable(self, *args, **kwargs):
|
|
24
|
+
raise ImmutableError("frozendict is immutable")
|
|
25
|
+
|
|
26
|
+
__setitem__ = _immutable
|
|
27
|
+
__delitem__ = _immutable
|
|
28
|
+
clear = _immutable
|
|
29
|
+
pop = _immutable
|
|
30
|
+
popitem = _immutable
|
|
31
|
+
setdefault = _immutable
|
|
32
|
+
update = _immutable
|
|
33
|
+
|
|
34
|
+
# ✅ Hashable
|
|
35
|
+
def __hash__(self):
|
|
36
|
+
if self._hash is None:
|
|
37
|
+
self._hash = compute_hash(self)
|
|
38
|
+
return self._hash
|
|
39
|
+
|
|
40
|
+
def copy(self):
|
|
41
|
+
return self
|
|
42
|
+
|
|
43
|
+
def with_updates(self, **changes):
|
|
44
|
+
data = dict(self)
|
|
45
|
+
data.update(changes)
|
|
46
|
+
return frozendict(data)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: frozendict-secure-x
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Author: sastha prasanth ramakrishnan
|
|
5
|
+
License: MIT
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Dynamic: license-file
|
|
10
|
+
|
|
11
|
+
# frozendict-secure-x ❄️
|
|
12
|
+
|
|
13
|
+
An immutable, hashable dictionary for Python.
|
|
14
|
+
|
|
15
|
+
Python has `tuple` and `frozenset`, but no built-in immutable dictionary.
|
|
16
|
+
This package provides a **safe, simple, and hashable `frozendict`**.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## ✨ Features
|
|
21
|
+
- ✅ Immutable (cannot be modified)
|
|
22
|
+
- ✅ Hashable (usable as dict keys & set items)
|
|
23
|
+
- ✅ Lightweight & fast
|
|
24
|
+
- ✅ Pythonic API
|
|
25
|
+
- ✅ Clear license & author attribution
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 📦 Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install frozendict-secure-x
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
frozendict/___init___.py,sha256=ENJFvJgFMQFVY0MJv8x5I90YbG-GGroDo7EG4EvLBAo,56
|
|
2
|
+
frozendict/_errors.py,sha256=EnoSjrZEIgOtVaaCi92r2knDQYCF38usBvOJMlZJl7g,143
|
|
3
|
+
frozendict/_hashing.py,sha256=dZNh5uYKoSdOGTZ0bgWFM5_vt7OoQjlxnYwAmB8LArQ,176
|
|
4
|
+
frozendict/core.py,sha256=YhyyVgXbLTs3-bBhov-fBMzx7jbFp5ZJthHKd13tG0E,1091
|
|
5
|
+
frozendict_secure_x-1.0.0.dist-info/licenses/LICENSE,sha256=itMayN-R9SsoKujZmYyqtXARhShK_1MgHdnp32qvTzg,62
|
|
6
|
+
frozendict_secure_x-1.0.0.dist-info/METADATA,sha256=4OBbqM3WXnse6LYedO4VKRyvoXJ69O1DW_o944612Jo,734
|
|
7
|
+
frozendict_secure_x-1.0.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
8
|
+
frozendict_secure_x-1.0.0.dist-info/top_level.txt,sha256=H0x_yOfp00xK1WR_JMHct-wr-7Ht9uC9iQR2aHNL_uw,11
|
|
9
|
+
frozendict_secure_x-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
frozendict
|