The API leaking all implementation details will remain available as an opt-in option for Cython, cffi and debug tools. But this API will only be usable on the "slow" Python runtime, the one which keeps maximum backward compatibility. To get new optimizations, you have to use Py_INCREF() and avoid accessing C strucuture fields, which may or may not need to modify your code.<br><br>Hum, please, join the capi-sig mailing list, since I already explained that in my long reply to Stefan on capi-sig ;-)<br><br>Victor<br><br>Le lundi 30 juillet 2018, Chris Angelico <<a href="mailto:rosuav@gmail.com">rosuav@gmail.com</a>> a écrit :<br>> On Mon, Jul 30, 2018 at 10:46 AM, Victor Stinner <<a href="mailto:vstinner@redhat.com">vstinner@redhat.com</a>> wrote:<br>>> 2018-07-29 23:41 GMT+02:00 Jeroen Demeyer <<a href="mailto:J.Demeyer@ugent.be">J.Demeyer@ugent.be</a>>:<br>>>> For example, you mention that you want to make Py_INCREF() a function call<br>>>> instead of a macro. But since Py_INCREF is very common, I would guess that<br>>>> this would make performance worse (not by much maybe but surely measurable).<br>>><br>>> For the very specific case of Py_INCREF(), yes, I agree that<br>>> performance is an issue. But I don't see how I would hide completely<br>>> the PyObject structure without converting Py_INCREF() macro with a<br>>> function call. (I have reasons to want to hide everything, explained<br>>> in the project.)<br>>><br>>> The open question is if the cost of using function calls for<br>>> Py_INCREF/DECREF versus the benefit of having the ability to modify<br>>> deeply CPython internals.<br>>><br>>> I'm not sure that it's worth to bet at this point, it's too early, and<br>>> we can decide that later. Moreover, it's also possible to keep<br>>> Py_INCREF() as a macro in the "backward compatible" mode, but require<br>>> a function call in the mode which hides all implementation details<br>>> (the one where you can experiment deep CPython internals changes).<br>>><br>><br>> If the macro and function are absolutely 100% compatible, it would be<br>> possible to set compilation to use the function by default, and have a<br>> directive that switches to using the macro. It'd improve performance<br>> at the price of locking you to the exact CPython build. So within<br>> CPython itself, there'd be no performance cost (ergo if you mess with<br>> the internals, you have to recompile all of CPython), most extension<br>> libraries would pay a small (probably immeasurable) price for<br>> compatibility, and a small handful could opt to improve performance at<br>> the price of breaking if anything changes.<br>><br>> ChrisA<br>> _______________________________________________<br>> Python-Dev mailing list<br>> <a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>> <a href="https://mail.python.org/mailman/listinfo/python-dev">https://mail.python.org/mailman/listinfo/python-dev</a><br>> Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/vstinner%40redhat.com">https://mail.python.org/mailman/options/python-dev/vstinner%40redhat.com</a><br>>