-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
GH-139389: Do not track immutable tuples in PyTuple_Pack #139390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
GH-139389: Do not track immutable tuples in PyTuple_Pack #139390
Conversation
I'm not sure that this needs a NEWS entry because it is an implementation detail. But I'm here on triage/core decision. |
Sorry, misclick. |
|
Which cases would benefit from this change to
Note: I used this code to check which cases are impacted
|
@eendebakpt Yeah, I did the same for:
Collecting stats and microbenchmarking now. |
Tests fail because instrumentation a bit straightforward and |
Tests will fail because I write stats to stderr. |
When we use
PyTuple_Pack
all objects already well constructed. If we know that they immutable we can skip tracking it in GC, because GC will untrack them eventually.I have a PR ready and benchmark results:
Geometric mean: 1.01x faster (Win11 x64, 11th Gen Intel(R) Core(TM) i5-11600K @ 3.90GHz, 48d0d0d)
All benchmarks:
Benchmark hidden because not significant (20): 2to3, chaos, deepcopy_reduce, genshi_xml, html5lib, json_loads, nqueens, pathlib, pickle, pickle_dict, pickle_list, pidigits, regex_dna, sqlglot_normalize, sqlglot_parse, sqlglot_transpile, sqlite_synth, sympy_integrate, unpickle_list, xml_etree_generate
It doesn't hurt performance, but can decrease number of objects in GC to check and untrack.