What's the proper way to clean up static python object references in a CPython extension module?

StackOverflow https://stackoverflow.com/questions/15688954

質問

The CPython headers define a macro to declare a method that is run to initialize your module on import: PyMODINIT_FUNC

My initializer creates references to other python objects, what is the best way to ensure that these objects are properly cleaned up / dereferenced when my module is unloaded?

役に立ちましたか?

解決

You can't unload C extension modules at all. There is just no way to do it, and I know for sure that most of the standard extension modules would leak like crazy if there was.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top