On 03Mar.2019 1206, Neil Schemenauer wrote:
On 2019-03-03, Nick Coghlan wrote:
Given the long history of the existing CPython C API, I think any new handle-based design is still going to have to support the invariant that "c_handle_X == c_handle_Y" <=> "python_object_X is python_object_Y".
What is not clear to me yet is how difficult it would be for other Python VMs to implement a handle API that gives that invariant. Based on some dicussion with Armin, it sounds like PyPy takes a significant performance hit to do that. If your GC can move objects, how do you efficiently implement that invariant?
FWIW, COM solves this issue by requiring that you cast differently typed pointers to the same interface (typically IUnknown) before comparing for identity.
In my opinion, you can dislike many of the Windows-specific "enhancements" around COM (like DCOM, etc., and I do dislike them), but the core concepts are very well proven, including being used from JavaScript and .NET (fully GC languages). Perhaps moreso than JNI?
Cheers, Steve