[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Python3 - How do I import a class from another file


> In common Python, small integers are cached internally for reuse

That is what I imagined could possibly be happening, reading the specific 
"the integer 5" formulation in the question ("reading between the lines" and 
all that).

And thanks for that explanation, underbuild an all.  :-)

> If you had an object on which you invoked "del", then it had a
> reference count, and if that reference count dropped to 0, then any
> __del__ method would be called.

That is exactly what I thought (the most logical thing), but Greg seemed to 
know better:

[quote: greg]
In that case, it was only working by accident. You were unwittingly
relying on the garbage collector to immediately clean up the object
as soon as the last reference to it disappeared.

My doubt to that (explicitily mentioning the __del__ method) was than picked 
up by Chris, who continued in the same vein.  After which the others started 
to pile up on me.

I hope you do realise that you are opening yourself up to those same guys ? 
After a few of those ontop of you quickly ceases to be funny. :-(

> Remember that reference counting, the main garbage collection
> mechanism in Python, can't be disabled.

Even /wanting/ to do so would be rather stupid, as it would mean the program 
would than be hemmoraging memory.

> The only garbage collection behavior you can
> alter is the generational garbage collector in the gc module.

Which I assume just takes care of compacting the available memory (and 
dealing with those (already found?) circular references).

Rudy Wieser