Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TODO list #34

Open
Marco-Sulla opened this issue Oct 24, 2021 · 4 comments
Open

TODO list #34

Marco-Sulla opened this issue Oct 24, 2021 · 4 comments
Labels
Needs: Doc Improvements or additions to documentation Priority: High A blocking bug or an important feature Type: Enhancement New feature or request

Comments

@Marco-Sulla
Copy link
Owner

Marco-Sulla commented Oct 24, 2021

New features for frozendict:

Bugs:

Internal cleanup:

  • try Py_TPFLAGS_IMMUTABLETYPE for CPython >= 3.10

DONE

  • __class_getitem__: https://github.com/python/cpython/pull/28450/files
  • dict_or also for python 3.6 - 3.8
  • Set up a CI/CD, as suggested by Lurch and explained here: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs-or-python?langId=py
  • remove asserts on old_value in frozendict_insert
  • remove ASSERT_CONSISTENT from _new
  • add ASSERT_CONSISTENT to fromkeys
  • replace copy method as in 3.9 for other versions
  • fix typo in PyFrozenDict_Check
  • make coold a subclass of frozendict
  • add new gc track control in frozendictiter_iternextitem introduced in dict 3.10
  • investigate why creation from dict is so slower than the dict constructor itself
  • restore old __reduce__ impl
  • implement reverse for all versions
  • do more tests
  • check that the code across the different py version is consistent, object by object, function by function
  • make the C extension working on Windows. Conda complains about it.
  • be sure all branches are tested
  • make a function for empty_frozendict generation
  • create a define for module name
  • rename _hash and _hash_calculated to ma_hash etc
  • deepcopy should return the frozendict untouched if it's hashable. But it seems that the trick to remove the function if it's not hashable and let the default deepcopy to fire does not work. Check how tuple works.
  • make executable created with cibuildwheel working on Debian ([BUG] v2.1.2 segfaults on Python 3.7 on Debian #41)
  • check original dict code to detect possible errors in frozendict
  • set()
  • delete()
  • setdefault()
  • remove coold
  • do not cache hash if hashing is not possible.
  • remove personal and controversial references from the tests and examples
  • key()
  • value()
  • item()
  • Add py only wheel on Conda
  • implement a memory leak tracer, like this one (thanks @lelit): https://github.com/python-rapidjson/python-rapidjson/blob/master/tests/test_memory_leaks.py
  • Ponder to remove the py wheel and make the C Extension optional
  • explore if there's a less hacky way to do the same test with different implementations of frozendict (pure py, C) with pytest, or explore other unit test frameworks. Possible solution: class tests.
  • restructure test dir
@Marco-Sulla Marco-Sulla added Type: Bug Something isn't working Needs: Doc Improvements or additions to documentation Type: Enhancement New feature or request Priority: High A blocking bug or an important feature and removed Type: Bug Something isn't working labels Oct 24, 2021
@NeilGirdhar
Copy link

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.

@Marco-Sulla
Copy link
Owner Author

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

@davaya
Copy link

davaya commented Dec 15, 2022

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

@Marco-Sulla
Copy link
Owner Author

To be honest, I already implemented it:

3a343a2

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Doc Improvements or additions to documentation Priority: High A blocking bug or an important feature Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants