Python3 - How do I import a class from another file

Daniel Haude dhaude at posteo.de
Wed Dec 11 11:53:16 EST 2019


Am 10.12.2019 22:29 schrieb Chris Angelico:

> And once again, you are maintaining your assumptions despite being
> very clearly shown that they are wrong. "del instance" does not
> directly call __del__ any more than "instance = 1" does. You HAVE been
> shown.

Much of the confusion in this thread comes from the murky distinction 
between "garbage collection" and "memory management." I wouldn't call a 
reference-counting system "garbage collection" per se.

Another bone of contention seems to be the question exactly WHEN 
reference counting and/or garbage collection release an object's 
resources (give it back to memory management). I read the word "when" in 
the non-implementation-specific Python docs as "immediately upon" (quote 
below, caps by me):

"Note: del x doesn’t directly call x.__del__() — the former decrements 
the reference count for x by one, and the latter is only called WHEN x’s 
reference count reaches zero."

It is then up to Python's memory management (PyMem_Alloc et al in 
CPython) what to do, and when: Give it back to the OS, keep it around 
for later use, whatever.



More information about the Python-list mailing list