
March 2, 2019
2:07 a.m.
If we implement PyHandle in CPython in a simple way (e.g. as a typecast from PyObject), I think we will have similar problems to what the Android runtime encountered around the release of Ice Cream Sandwich. See:
https://android-developers.googleblog.com/2011/11/jni-local-reference-changes-in-ics.html
Again, a possible solution might be a debug build option CPython that uses indirect pointers for the handles and checks that the API is used correctly. Or, if we went with a JNIEnv* like vtable, you could have a command-line flag that switched CPython to use indirect pointers for handles.