I have a python class where in its init calls Cpython code allocating memory using c++ constructs in memory data store.
I want to delete the newly created element in the data store when the corresponding python object gets garbage collected.
I looked into gc documentation, I found thé callable feature. But it’s supported since python 3.3 and I use 2.7.
So is there an alternative to the callable feature ? Thanks
I found an alternatrive:
I simply did override __del__
function in Python class to call a Cpython extension function that frees the corresponding object.