I have a python set that contains a collection of non-hashable python objects with uniform type which I want to process.
To improve efficiency of my algorithms, I would like to interface using ctypes with an external index implementation that accepts only uint64 as data values.
I was hoping that I could to pass pointer references to the python object into this external library as uint64?
I tried ctypes.cast(ctypes.py_object(my_python_object), ctypes.c_uint64) but am getting ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type.
Also, what about the reverse, getting a reference to a python object as uint64 and turning it into a "real" python object?
id()?id()value? If not, I could always convert mysetinto adictwith the ids as keys.id()- instead you will crash your interperter :DPyDLLinstance that holds the GIL when calling functions. Then just set the function'sargtypes, with the Python object parameter defined aspy_object. The C function will handle this as auint64_t. Passing the object directly increments the reference count during the call, so there's no danger of the object getting deallocated on another thread.