Repository navigation
📝 docs: prefer the built-in frozendict on Python 3.15+ - #79
Merged
nstarman merged 1 commit intoOct 10, 2026
Merged
Conversation
JAX 0.11.2 registers the PEP 814 built-in as a PyTree node, so the README's claim that JAX treats it as a leaf is out of date. Recommend the built-in on 3.15+ and warn that its leaves flatten in sorted-key order, unlike ImmutableMap's insertion order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #79 +/- ##
========================================
Coverage ? 100.00%
========================================
Files ? 3
Lines ? 75
Branches ? 0
========================================
Hits ? 75
Misses ? 0
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
JAX 0.11.2 (2026-09-17) registers the built-in
frozendict(PEP 814) as a PyTree node, which makes the README's "Relationship tofrozendict" section out of date: it says JAX treats the built-in as an opaque leaf and that this package can retire once JAX registers it upstream.This PR:
frozendicton Python 3.15+ withjax>=0.11.2, and keepsImmutableMapas the option for Python < 3.15.frozendictthe way it flattensdict: leaves come out in sorted-key order, unflattening rebuilds the map in sorted order, and keys that can't be sorted raise an error.ImmutableMapflattens in insertion order, so forImmutableMap(b=1, a=2)the leaves are[1, 2], while forfrozendict(b=1, a=2)they are[2, 1].Verified on CPython 3.15.0 with jax 0.11.2 (treedef
PyTreeDef(frozendict({'a': *, 'b': *})), round-tripping throughjitreturns afrozendict). On 3.13,pytestpasses (113 tests, including the README blocks via Sybil) and the pre-commit hooks pass.A follow-up PR will make
ImmutableMapflatten in sorted-key order as well, so that switching types doesn't change leaf order.🤖 Generated with Claude Code