markshannon / New-C-API-for-Python

Design and discussion for the new C-API for Python
Creative Commons Zero v1.0 Universal
15 stars 1 forks source link

Address reference-handling performance #10

Closed encukou closed 2 years ago

encukou commented 2 years ago

Apparently, making the current Py_INCREF/Py_DECREF be regular (non-inline) functions is too slow. I don't see how the proposed PyRef_Dup/PyRef_Free would end up being called significantly less often than the current incref/decref. This proposal specifies ABI stability (“code compiled to older versions of the API will continue to work”), so it seems it'll either use static functions/macros and prevent changes to the refcounting mechanism, or export regular functions which will be too slow. Am I missing something? Is there a way out?

markshannon commented 2 years ago

The No ABI mode provides a way to get performance, at the cost of binary compatibility. If you want top performance, you'll need to re-compile for different version and implementations.

HPy does something similar, maybe they have some data on the actual performance impact.