python-frozendict
python-frozendict copied to clipboard
TODO list
New features for frozendict:
- support for Python 3.11 in the C Extension (WIP) #68
- improve JSON and pickle speed #76
- delete_by_index()
- Slicing
- index()
- move()
- insert()
- sort()
- getdeep(): https://github.com/Marco-Sulla/python-frozendict/issues/14
- keysof(): https://github.com/Marco-Sulla/python-frozendict/issues/13
- the entire Set API (?)
- Possibility to get a value from frozendict values object by index
- Possibility to get a key from frozendict keys object by index
- Possibility to get a item from frozendict items object by index
- restore freelists for 3.10+. Explore thread safe solutions.
- optimize reverse
Bugs:
- #71
Internal cleanup:
- try
Py_TPFLAGS_IMMUTABLETYPEfor CPython >= 3.10
Type annotations?
Also, Python 3.6 is end of life in 3 weeks, so it might simplify annotations to use Python 3.7 features immediately.
@NeilGirdhar It seems to me that type annotations works with frozendict. Now from python 3.9+ you can also write frozendict[type, type].
+1 for deepfreeze (#30).
I need to determine if list items are unique, i.e. if len([a, b, c]) == len(set([a, b, c])) where a, b, c can be anything including nested dicts.
a = [{'x': 1}, {'y': 2}, {'x': 3}, 'foo', 4]
b = [{'x': 1}, {'y': 2}, {'x': 1}, 'foo', 4]
c = [{'x': 1}, {'y': {'y2': 2}}, {'x': 1}, 'foo', 4]
b2 = [frozendict(x) if isinstance(x, dict) else x for x in b]
c2 = [frozendict(x) if isinstance(x, dict) else x for x in c]
print(len(b2))
print(len(set(b2))) # works
print(len(set(c2))) # fails
Since a hashable/frozen dict isn't already part of standard Python for some reason, thank you so much for creating it, and TIA for making it deep.
To be honest, I already implemented it:
https://github.com/Marco-Sulla/python-frozendict/commit/3a343a2b9ca023053c3a896a99d51f693a180b49
The problem is I would add a way to register your own mutable type with a callable that makes it immutable. And tests. A lot of tests.