Following up on shapely/shapely#501
In C, a python object is just a pointer (PyObject *) to a struct which includes some standard members, but may include additional ones. Cython static attributes end up there. Accessing these from C does not include the overhead. If I look at https://docs.python.org/3/extending/newtypes_tutorial.html, I could create an (immutable) extension type with pointer as additional attribute and with a custom tp_dealloc that calls the GEOSDestroy_r.
The advantage would be that we leverage python/numpy's reference counting and on the garbage collector to deallocate stuff.
Following up on shapely/shapely#501
In C, a python object is just a pointer (PyObject *) to a struct which includes some standard members, but may include additional ones. Cython static attributes end up there. Accessing these from C does not include the overhead. If I look at https://docs.python.org/3/extending/newtypes_tutorial.html, I could create an (immutable) extension type with pointer as additional attribute and with a custom tp_dealloc that calls the GEOSDestroy_r.
The advantage would be that we leverage python/numpy's reference counting and on the garbage collector to deallocate stuff.