Hi all,
one of our Python projects calls for pretty heavy, low-level optimizations.
We went down the rabbit hole and determined that having access to PyList_GET_ITEM(list), PyInt_AS_LONG(int) and PyDict_GetItem(dict, unicode) on Python objects **outside of GIL** might be a good-enough solution. The Python objects in question are guaranteed to live and not be mutated externally in any way. They're "frozen" and read-only.
Under what conditions is it OK to call these 3 functions on such objects?
More generally, what is the CPython 2.7/3.5 contract regarding (lack of) object mutation, and the need for reference counting and synchronization via GIL?
Which C API functions are safe to call on "const" objects?