Skip to content

gh-145478: Implement frozendict into functools.partial#145960

Open
bkap123 wants to merge 2 commits intopython:mainfrom
bkap123:frozen-dict-partial
Open

gh-145478: Implement frozendict into functools.partial#145960
bkap123 wants to merge 2 commits intopython:mainfrom
bkap123:frozen-dict-partial

Conversation

@bkap123
Copy link
Contributor

@bkap123 bkap123 commented Mar 15, 2026

Changes:

  • partial.__setstate__ takes any dict for keywords and checks keywords to make sure that they are strings
  • changed some tests to make sure they still make sense when working with a frozendict (rather than a dict)
  • change pickle tests to use protocols 2+, but am not sure if this is the best solution or if there is a problem not using protocols 0 or 1. I made this change since frozendict does not work for these lower numbed protocols

📚 Documentation preview 📚: https://cpython-previews--145960.org.readthedocs.build/

@bkap123
Copy link
Contributor Author

bkap123 commented Mar 15, 2026

cc @encukou since you originally suggested this change.

@bkap123
Copy link
Contributor Author

bkap123 commented Mar 15, 2026

Most of the test errors are due to problems with pickling the partial object, due to the fact that frozendict does not work for all protocols. I'm not sure what the best approach is, but one solution might be to define __reduce_ex__ for partial and have it create a temporary dict for certain protocols instead of using a frozendict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant