osdir.com


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

Python3 - How do I import a class from another file


Greg,

> In CPython, these are the same thing. As soon as the reference
> count becomes zero, the __del__ method is called

That is what I assumed (the logical thing to do).

> *and* the object is removed from memory.

Which sounds reasonable too, especially in regard to the instances variables 
needing to be removed, which could possibly hold external references.

Than again, releasing those variables could have been done just after 
calling the __del__ method, with the releasing of the used memory and 
compacting done at a later point in time.   Multiple possibilities.

> But without reference counting, it has no way of
> *knowing* that it's the last reference until the garbage
> collector does its thing.

Blimy.  You've certainly got a point there.

> To demonstrate that with a code example, it would have to be run on a 
> different implementation of Python
> that didn't use reference counting, such as Jython.

I was rather clear about what my used version of Python was-and-is.  I have 
no idea why that was ignored. :-(

As a newbie I do not yet have much use for "it isn't true on version X on 
platform Y, so you're wrong" kind of replies.  Especially not when only the 
"you're wrong" part is posted ...

A question though: I have brought up that a delayed calling of the __del__ 
method could/would most likely cause race problems.  Do you have any idea 
how thats solved in environents like Jython ?

It looks to me that if you would want to have the (for example) file closed 
when you close the instance you would need to do quite a bit of manual 
keeping-track-of the instances.

Regards,
Rudy Wieser