Skip to content

gh-141510, PEP 814: Add frozendict support to pickle#144936

Draft
vstinner wants to merge 4 commits intopython:mainfrom
vstinner:frozendict_pickle
Draft

gh-141510, PEP 814: Add frozendict support to pickle#144936
vstinner wants to merge 4 commits intopython:mainfrom
vstinner:frozendict_pickle

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Feb 17, 2026

@vstinner
Copy link
Member Author

I mark the PR as a draft since test_pickle fails on the test that I added:

FAIL: test_recursive_frozendict_and_inst (test.test_pickle.InMemoryPickleTests.test_recursive_frozendict_and_inst) (proto=5)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vstinner/python/main/Lib/test/pickletester.py", line 2852, in _test_recursive_collection_and_inst
    self.assertIs(list(x)[0].attr, x)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
AssertionError: frozendict({<test.picklecommon.Object object at 0x200009adea0>: None}) is not frozendict({<test.picklecommon.Object object at 0x200009adea0>: None})

@vstinner
Copy link
Member Author

I mark the PR as a draft since test_pickle fails on the test that I added

Ah it's ok, I found the issue: the C implementation was not correct. It's not fixed.

@vstinner vstinner marked this pull request as ready for review February 18, 2026 17:19
@vstinner
Copy link
Member Author

cc @serhiy-storchaka @avassalotti

@serhiy-storchaka
Copy link
Member

You do not need to change the pickle module. Just add the __getnewargs__() method returning (dict(self),) or (list(self.items()),).

Adding a new pickle opcode requires a separate PEP.

@vstinner
Copy link
Member Author

You do not need to change the pickle module. Just add the __getnewargs__() method returning (dict(self),) or (list(self.items()),).

Oh, I didn't know that it was so simple :-) I wrote #144967 to implement __getnewargs__().

@vstinner vstinner marked this pull request as draft February 18, 2026 18:20
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.

2 participants

Comments