Fix to_builtins with frozendict - #1105
Merged
Merged
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
Siyet
previously approved these changes
Jul 2, 2026
Siyet
left a comment
Contributor
There was a problem hiding this comment.
LGTM, thanks for the quick follow-up! Did a deep pass on 5a54d59 including an empirical run on 3.15.0a7.
Verified:
- The #1104 repro is fixed: enum keys/values and nested frozendicts convert in both modes,
str_keysandorderare honored now, plain-dict parity holds for content and ordering in all threeordermodes, and the type is preserved only withbuiltin_types=(frozendict,)- matching the flag's intent from #1052. - Refcounting is clean on every path:
_PyFrozenDict_NewSteal's NULL-guard covers theto_builtins_dicterror paths (enc_hook raise, unsortable keys withorder,str_keysTypeError), and 100k-300k iteration loops over both happy and error paths show zero RSS/gc-object growth. - No dict-path regression (byte-identical behavior for plain dict, with and without the flag), encoders/
convertuntouched as they should be, builds and full suite green on 3.12 (PY315_PLUSoff) and 3.15, including the PR diff re-applied onto current main.
Three small notes, none blocking:
- In
test_frozendict_builtin_types_sortedtheassert_eqhelper only checks ordering underif isinstance(left, typ)- if the fix ever regressed to returning a plaindict, equality would still pass (frozendict == dict) and the order check would silently skip, so the test would stay green without testing anything. Anassert isinstance(left, typ)(or atype(res) is frozendictpin in the test) closes that - same lesson as thetest_order_frozendictfix in #1107. - The PR body has no
Closes #1104, so the issue won't auto-close on merge - worth adding. - Optional: one test line for a frozendict subclass input (it now collapses to exact
frozendict/dict, consistent with dict-subclass behavior, but nothing pins that).
Member
Author
|
I've updated tests and will merge it once CI passes. |
Member
Author
|
@Siyet thanks a lot for your review! Really helpful. |
pull Bot
pushed a commit
to Future-Outlier/msgspec
that referenced
this pull request
Jul 3, 2026
Batches the changelog entries accumulated since the 0.21.1 release, following the usual pre-release batching practice (like msgspec#1020). Covers merged user-facing changes through msgspec#1109/msgspec#978/msgspec#1105; internal CI/benchmarking/test-infra changes are intentionally omitted. Also records the move to the msgspec GitHub organization. --------- Co-authored-by: Siyet <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Now it follows the same rules as
dict:)orderkeywordCloses #1104