[Python-Dev] PyGC_Collect ignores state of enabled
(original) (raw)
Ethan Furman ethan at stoneleaf.us
Wed May 18 15:04:23 EDT 2016
- Previous message (by thread): [Python-Dev] PyGC_Collect ignores state of `enabled`
- Next message (by thread): [Python-Dev] PyGC_Collect ignores state of `enabled`
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 05/18/2016 11:52 AM, Neil Schemenauer wrote:
Benjamin Peterson wrote:
Adding PyGCCollectIfEnabled() and calling it in PyFinalize is probably fine. I don't think the contract of PyGCCollect itself (or gc.collect() for that matter) should be changed. You might want to disable GC but invoke it yourself. Yes, that sounds okay to me. I poked around at the calls to PyGCCollect() and PyGCCollectNoFail(). The cyclic garbage collector gets invoked at least three times during shutdown. Once by PyFinalizeEx() and two times by PyImportCleanup(). That seems a bit exessively expensive to me. The collection time can be significant for programs with a lot of "container" objects in memory. The whole finalize/shutdown logic of the CPython interpreter could badly use some improvement. Currently it is a set of ugly hacks piled on top of each other. Now that we have PEP 3121, Extension Module Initialization and Finalization https://www.python.org/dev/peps/pep-3121/ we should be able to cleanup this mess. PyImportCleanup() is the main area of trouble. I don't think we should not be clearing sys.modules and we should certainly not be clearing module dicts. If there is some whippersnapper out there who wants to get their hands dirty with Python internals, fixing PyImportCleanup() would be a juicy project.
Is there an issue filed for it?
--
Ethan
- Previous message (by thread): [Python-Dev] PyGC_Collect ignores state of `enabled`
- Next message (by thread): [Python-Dev] PyGC_Collect ignores state of `enabled`
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]