You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
json.dumps: single circle markers hash lookup #161661
Right now the code does Contains + SetItem for circular reference checks. That can be done as a single hash lookup with PyDict_SetDefault and checking the dictionary size (memory read).
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Updated to PyDict_SetDefaultRef for a cleaner approach. On a synthetic case with a lot of containers it gives me ~4.5% improvement. For pyperformance it's insignificant 0.x% change.
Now with SetDefaultRef I think it's also a cleaner code regardless of perf gains or not.
Activity
picnixz commentedon Nov 9, 2026
How much perf do we gain?
aivarsk commentedon Nov 9, 2026
Updated to
PyDict_SetDefaultReffor a cleaner approach. On a synthetic case with a lot of containers it gives me ~4.5% improvement. For pyperformance it's insignificant 0.x% change.Now with SetDefaultRef I think it's also a cleaner code regardless of perf gains or not.