-
Notifications
You must be signed in to change notification settings - Fork 795
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
vectorcall: fix bindings & use for call0 and call_method0 #1287
Conversation
84f6834
to
c85c25b
Compare
c85c25b
to
423c575
Compare
Windows failing to link on abi3 - presumably it's us doing something wrong; I'm asking about it at https://bugs.python.org/issue42415 |
2ef2771
to
9df2e15
Compare
Rather than wait for that bug to be resolved (which I guess might not happen until Python 3.9.1) I've put a TODO in the code and just enabling the optimization for the unlimited API for now. |
9df2e15
to
e48399c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. This is a pretty good step towards vectorizing function calls. Comments are mainly around FFI definitions.
|
||
#[cfg(all(Py_3_8, not(PyPy)))] | ||
#[inline(always)] | ||
pub unsafe fn _PyObject_FastCallTstate( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this function? (I'm looking at https://github.com/python/cpython/blob/v3.8.6/Include/cpython/abstract.h ).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm looking at the same file but the version in master
(so 3.10-dev
). I figured it was best for these inline functions to be as up-to-date as possible.
// skipped _PyObject_VectorcallMethodId | ||
// skipped _PyObject_CallMethodIdNoArgs | ||
// skipped _PyObject_CallMethodIdOneArg | ||
|
||
// skipped _PyObject_HasLen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, why are they skipped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't consider them relevant to my PR; I could add them but I'd also quite like to keep as few unlimited API definitions as possible (as they're more likely for us to be work to maintain).
See also #1289 which talks a bit about what I'm thinking.
@@ -0,0 +1,3 @@ | |||
pub mod abstract_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for creating this new module. Maybe we can reduce cfg
using this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think for sure (again see #1289).
6d5c5cf
to
4d14ac8
Compare
4d14ac8
to
9e99f01
Compare
9e99f01
to
87bacf1
Compare
Thanks! |
This PR fixes the broken vectorcall ffi bindings, and proves that the new ones work by using them in
.call0
and.call_method0
implementations (where possible).This yields quite a tidy ~20% performance speedup on those functions, because it no longer creates an empty
PyTuple
andPyDict
each time:before:
after:
I'd love to follow this PR up with some ways to use vectorcall for functions with arguments too. Will leave that for #684 instead of pushing this further right now.
Closes #1283