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
complex() constructor bypasses the existing freelist #162428
complex has a freelist but complex(...) always allocates through complex_subtype_from_c_complex() which misses it.
a=1.5; z=1jx=z*z; i=id(x); delxid(complex(a, a)) ==i# False on main
Using PyComplex_FromCComplex() for exact complex, as float_new_impl() does with PyFloat_FromDouble(), makes exact complex(...) calls 1.12x-1.29x faster in microbenchmarks; subclasses are unchanged.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
changed the title [-]complex() constructor results bypass the complex freelist[/-][+]complex() constructor bypasses the existing freelist[/+]on Nov 22, 2026
Activity
[-]complex() constructor results bypass the complex freelist[/-][+]complex() constructor bypasses the existing freelist[/+]gh-162428: Use the freelist for exact `complex()` constructor results (…