-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-126703: add freelist for PyComplexObject's #135233
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?
Conversation
@skirpichev Would you like to provide benchmark enhancement for this change? |
Oops, I just forgot to post one. Description updated. |
Please share the pyperformance benchmark results. |
Well, it shouldn't be affected. This collection has no benchmarks for complex math at all:
Probably less than floats, but not too much. |
AFAICS, real-world workloads that don't use complex numbers will pay the price of:
In applications that do use complex numbers, is it likely that they need to create/destroy them quickly? To review this I'll need to teach myself about Python's freelists; I can do that next week. |
I believe that we use pyperformance benchmark as the real world proxy. So if there is no benchmark for it, I am unsure. At least someone needs to share the benchmark for this. If not, people will add new PR for other built-in types with a microbenchmark, which would not be worth adding. We need criteria for this. |
Yes, just a new empty
That happens in every arithmetic operation. Here is a benchmark with a simple sin() implementation:
# bench2.py
def mysin(z):
i, lasts, s, fact, num, sign = 1, 0, z, 1, z, 1
while s != lasts:
lasts = s
i += 2
fact *= i*(i-1)
num *= z*z
sign *= -1
s += num/fact*sign
return s
import pyperf
runner = pyperf.Runner()
runner.bench_func('mysin(1j)', mysin, 1j)
runner.bench_func('mysin(1+1j)', mysin, 1+1j)
You are not alone, this is new for me as well :D IIUC (see help topic), this technique is not something, allowed for external C extensions.
I doubt we have too much built-in types. Being a built-in type is a sign from the real world too ;-) |
Micro-benchmark: