As I understand it:
With Py_LIMITED_API
set to be an older Python version (e.g. 0x030700
) the reference counting macros don’t account for immortal objects due to the need to maintain backwards compatibility. That isn’t a disaster but it makes things less efficient.
If you use the reference counting functions (Py_IncRef
) instead then they’re handled correctly.
My opinion was that if you changed to using functions, then you should change everything (so you don’t end up in a situation where the incref is skipped but the decref isn’t, for example).
However, there doesn’t seem to be function versions for XINCREF
, XDECREF
, CLEAR
, (X)SETREF
.
Any advice on using these in the limited API if I want immortal objects to be untouched?