Le jeu. 6 sept. 2018 à 13:30, Ronald Oussoren ronaldoussoren@mac.com a écrit :
PyTuple_GetItem should be fairly safe, if the callers owns a reference to the tuple itself. It is technically possible that tuples change, but that’s bad behaviour (similar to how C code can change the contents of strings, which would break assumptions in other code).
It seems like you completely missed my point about borrowed references. I rewrote the rationale to remove borrowed references using Antonio Cuni's email: https://pythoncapi.readthedocs.io/bad_api.html#problem-caused-by-borrowed-re...
In short, you are describing the exact implementation of CPython 3.7. I care of PyPy cpyext, other Python implementations, and also deep changes in CPython internals (things that I called experimental optimization ideas). In PyPy, there is no such thing as PyObject, so you cannot point to a PyObject, since it doesn't exist... Well, see the rationale.
Victor