On 2018-06-18 15:09, Victor Stinner wrote:
There are multiple issues with tp_fastcall:
Personally, I think that you are exaggerating these issues.
Below, I'm writing the word FASTCALL to refer to tp_fastcall in your patch as well as my C call protocol in the PEP-in-progress.
- ABI issue: it's possible to load a C extension using the old ABI,
without tp_fastcall: it's not possible to write type->tp_fastcall on such type. This limitation causes different issues.
It's not hard to check for FASTCALL support and have a case distinction between using tp_call and FASTCALL.
- If tp_call is modified, tp_fastcall may be outdated.
I plan to support FASTCALL only for extension types. Those cannot be changed from Python.
If it turns out that FASTCALL might give significant benefits also for heap types, we can deal with those modifications: we already need to deal with such modifications anyway for existing slots like __call__.
- Many public functions of the C API still requires the tuple and dict
to pass positional and keyword arguments, so a compatibility layer is required to types who only want to implement FASTCALL. Related issue: what is something calls tp_call with (args: tuple, kwargs: dict)? Crash or call a compatibility layer converting arguments to FASTCALL calling convention?
You make it sound as if such a "compatibility layer" is a big issue. You just need one C API function to put in the tp_call slot which calls the object instead using FASTCALL.
2018-06-19 13:58 GMT+02:00 Jeroen Demeyer J.Demeyer@ugent.be:
Personally, I think that you are exaggerating these issues.
I'm not trying to convince you to abandon the idea. I would be happy to be able to use FASTCALL in more cases! I just tried to explain why I chose to abandon my idea.
FASTCALL is cute on tiny microbenchmarks, but I'm not sure that having spent almost one year on it was worth it :-)
Victor
Victor Stinner schrieb am 19.06.2018 um 16:59:
2018-06-19 13:58 GMT+02:00 Jeroen Demeyer J.Demeyer@ugent.be:
Personally, I think that you are exaggerating these issues.
I'm not trying to convince you to abandon the idea. I would be happy to be able to use FASTCALL in more cases! I just tried to explain why I chose to abandon my idea.
FASTCALL is cute on tiny microbenchmarks, but I'm not sure that having spent almost one year on it was worth it :-)
Fastcall is actually nice, also because it has a potential to *simplify* several things with regard to calling Python objects from C.
Thanks for implementing it, Victor.
Just to add another bit of background on top of the current discussion, there is an idea around, especially in the scipy/big-data community, (and I'm not giving any guarantees here that it will lead to a PEP + implementation, as it depends on people's workload) to design a dedicated C level calling interface for Python. Think of it as similar to the buffer interface, but for calling arbitrary C functions by bypassing the Python call interface entirely. Objects that wrap some kind of C function (and there are tons of them in the CPython world) would gain C signature meta data, maybe even for overloaded signatures, and C code that wants to call them could validate that meta data and call them as native C calls.
But that is a rather big project to undertake, and I consider Jeroen's new PEP also a first step in that direction.
Stefan