Repository navigation
Avoid copying entire mappings during type inference - #7057
Conversation
[Medium impact] The PR appears safe to merge. Summary
No actionable issues were found. Tests were inspected, not run. Reviews (3) · Last reviewed commit: "Merge branch 'main' into codex/perf-boun..." · Reviewed by Greptile |
Merging this PR will degrade performance by 0.44%2 warnings
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing |
There was a problem hiding this comment.
No issues found across 4 files
Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack
View guided diff | Turn on auto-fix | Re-trigger cubic
# Conflicts: # tests/units/reflex_base/vars/test_base.py
Mapping type inference samples only 100 keys and values, but currently materializes every key and value before taking that sample. Use bounded iteration so inference keeps the same sample and resulting types without copying or retrieving the rest of a large mapping.
On a local CPython 3.14.5 / Apple M5 Pro benchmark, inference for a one-million-entry dict fell from 5.62 ms to 0.026 ms, with peak traced temporary allocation falling from 8 MB to 360 B. This measures the inference helper, not whole-app compilation. Added a CodSpeed benchmark across mapping sizes and regressions covering empty mappings, the exact sample boundary, and custom Mapping iteration/value access. The bounded-iteration regression fails on the unchanged base.
Validation:
pyright reflex testsand changed-file type checks passed.Independent of the other performance changes; based directly on main.