| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Sorry, something went wrong.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead. |
Sorry, something went wrong.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead. |
Sorry, something went wrong.
|
@andrewloux Your own benchmarks show this change is performance neutral. Unless there are additional result that show why this change is a significant improvement, I suggest we close this. (I do believe this is a tiny net improvement, but in general we avoid making such small changes to reduce churn and potential unforeseen issues) |
Sorry, something went wrong.
Yup, totally makes sense - let's close this 👍🏽 Thanks @eendebakpt |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
This PR replaces PyTuple_Pack with PyTuple_FromArray in Objects/dictobject.c within the dictitems_xor_lock_held function.
By avoiding the variadic argument (va_args) processing overhead of PyTuple_Pack, we reduce the per-item cost of symmetric difference operations (dict.items() ^ dict.items()) that involve value mismatches. The change uses a stack-allocated array to pass arguments directly to the tuple constructor.
Benchmarks (PGO+LTO)
Validated using pyperf in --rigorous mode on a full production build.
Geometric mean: 1.00x faster (1.01x on target path)
Repro commandsAnalysis
The dict_items_xor_overlap_neq workload specifically exercises the modified path by comparing dictionaries with overlapping keys but unequal values, triggering a tuple creation for every mismatched entry.
While the aggregate effect is a micro-optimization, the results show a consistent improvement on the target path with a reduction in variance (±4.6 ms → ±2.5 ms) across multiple runs. Control workloads (equal and disjoint) remain neutral, confirming no regressions in non-target dictionary shapes.