◐ Shell
clean mode source ↗

Message 353603 - Python tracker

> Would [func tp_clear] help with memory usage in functions or was BPO-33418 addressed in another way since?

Having a tp_clear for all container objects that can be involved in reference cycles will help the GC free memory.  BPO-33418 may be contrived but it does demonstrate a problem that could happen in "real" code.  If you have a long-running program, tracking down a memory leak due to reference cycles can be fiendishly difficult.  That's why Tim originally wrote cyclops and why I started working on cyclic GC in the first place.

It is a "quality of implementation" issue.  It is not wrong for CPython to leak memory if you create reference cycles (not all types are required to implement the GC protocol).  I expect users would be surprised if it happens since the majority have never used Python without the cyclic GC.