-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Python reports vectorcall as available even when using it will not help and even hurt performance #123372
Comments
As the docs mention, vectorcall support is a per-class property. For most Python functions, vectorcall is faster, so the function type implements vectorcall.
It is possible to disable vectorcall function per instance, but that's not the only thing that would need to change: Python functions would also need to implement tuple-and-dict calls, which they currently don't. In fact, there is a substantial chunk of code that passes arguments in the vectorcall format -- from
All this would need a separate code path in order to preserve a tuple. I doubt that it would be worth the speedup for |
There is no clear way forward, so I'll close this. |
Bug report
Bug description:
The following Python function
Has vectorcall enabled (
PyVectorcall_Function()
returns a non-NULL function), but because it collectsargs
, Python needs to convert the arguments into a tuple, and so vectorcall won't be any faster than allocating a tuple directly.This is not a problem if we know the number of arguments beforehand, but if we allocate the array for vectorcall, we will allocate twice needlessly.
Avoiding allocating for vectorcall also does not always provide the best performance, because vectorcall can have an edge with bound methods with the flag
PY_VECTORCALL_ARGUMENTS_OFFSET
.Per the docs:
As such, I believe this function (and similar functions) should not implement vectorcall.
Originally reported on Stack Overflow.
CPython versions tested on:
3.12
Operating systems tested on:
Windows
The text was updated successfully, but these errors were encountered: