bpo-42064: Offset arguments for PyObject_Vectorcall in the _sqlite module by encukou · Pull Request #27931 · python/cpython
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 new_statement_cache and get_statement_from_cache will benefit from this. OTOH, it won't hurt to use the encouraged calling convention :)
Comment on lines +67 to +68
| PyObject *inner = PyObject_Vectorcall( | ||
| lru_cache, args + 1, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); |
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.
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); |
encukou
deleted the
sqlite-vectorcall-offset
branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters