python-frozendict icon indicating copy to clipboard operation
python-frozendict copied to clipboard

TODO list

Open Marco-Sulla opened this issue 4 years ago • 4 comments

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_IMMUTABLETYPE for CPython >= 3.10

Marco-Sulla avatar Oct 24 '21 20:10 Marco-Sulla

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 avatar Dec 05 '21 16:12 NeilGirdhar

@NeilGirdhar It seems to me that type annotations works with frozendict. Now from python 3.9+ you can also write frozendict[type, type].

Marco-Sulla avatar Dec 16 '21 19:12 Marco-Sulla

+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.

davaya avatar Dec 15 '22 20:12 davaya

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.

Marco-Sulla avatar Dec 16 '22 23:12 Marco-Sulla