bpo-42064: Offset arguments for PyObject_Vectorcall in the _sqlite module by encukou · Pull Request #27931 · python/cpython

@encukou

@encukou

This allows e.g. methods to be called efficiently by providing
space for a "self" argument; see PY_VECTORCALL_ARGUMENTS_OFFSET docs.

@corona10

Out of curiosity, How efficient? is there any benchmark?

@encukou

Out of curiosity, How efficient? is there any benchmark?

I'm not aware of one, but the docs say this is encouraged :)

shihai1991

@erlend-aasland

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 :)

erlend-aasland

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

@encukou

erlend-aasland

@encukou encukou deleted the sqlite-vectorcall-offset branch

August 31, 2021 12:34

@encukou