pyamgx
pyamgx copied to clipboard
Use weak references to automate object cleanup
Currently, all pyamgx objects must be explicitly cleaned up by calling a .destroy()
method, but it should be possible to automatically clean up objects when they go out of scope (or at exit), using weakref.finalize
- Python >= 3.4 only.
Work on this has been started at https://github.com/shwina/pyamgx/tree/0.2dev. We don't really need to use weakref.finalize
-- Cython's __dealloc__
works fine to automate cleanup. We just need to be careful to keep references to upstream objects: for example, each Vector
should keep a reference to the Resources
object it depends on.