-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
bpo-42064: Offset arguments for PyObject_Vectorcall in the _sqlite module #27931
Conversation
This allows e.g. methods to be called efficiently by providing space for a "self" argument; see PY_VECTORCALL_ARGUMENTS_OFFSET docs.
Out of curiosity, How efficient? is there any benchmark? |
I'm not aware of one, but the docs say this is encouraged :) |
LGTM, thanks for spotting this! This makes sense for the collation callback, but I can't see how the calls in |
Modules/_sqlite/connection.c
Outdated
PyObject *inner = PyObject_Vectorcall( | ||
lru_cache, args + 1, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); |
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.
Could you please break lines according to PEP 7? I'm striving to keep all sqlite3
changes PEP 7 compliant :)
Ditto for the other calls.
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.
That is, either:
PyObject *inner = PyObject_Vectorcall( | |
lru_cache, args + 1, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); | |
PyObject *inner = PyObject_Vectorcall(lru_cache, args + 1, | |
1 | PY_VECTORCALL_ARGUMENTS_OFFSET, | |
NULL); |
or:
PyObject *inner = PyObject_Vectorcall( | |
lru_cache, args + 1, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); | |
size_t nargs = 1 | PY_VECTORCALL_ARGUMENTS_OFFSET; | |
PyObject *inner = PyObject_Vectorcall(lru_cache, args + 1, nargs, NULL); |
Thanks for the reviews! |
This weird mechanism allows e.g. methods to be called efficiently by providing space for a "self" argument; see PY_VECTORCALL_ARGUMENTS_OFFSET docs.
https://bugs.python.org/issue42064