Fredrik Lundh wrote:
> Jeffrey Schwab wrote:
> 
> 
>>>>>the problem isn't determining who owns it, the problem is determining
>>>>>who's supposed to release it.  that's not a very common problem in a
>>>>>garbage-collected language...
>>>>
>>>>Yes it is.  Memory is only one type of resource.
>>>
>>>Python's garbage collector deals with objects, not memory.
>>
>>But you don't want to spin and wait for the garbage collector to release
>>the object that happens to be holding a thread lock...
> 
> 
> no, but arguing that sockets and thread locks are objects that suffer
> from ownership problems is rather silly.

Why?  Are those resources somehow less important than memory?

> if their use isn't localized to a
> single function or a single manager object, your design is flawed.

!

I disagree.  Suppose some code is written to work with any file-like 
object.  Now suppose a file-like object is passed in that represents 
some URL.  The first time the object is read, the object opens a 
suitable network connection.  When is it safe to close that connection? 
  The client code can't say, because it doesn't even know any network 
connection has been opened.  In a language with deterministic 
destructors, the destructor can be relied on to close the connection as 
soon as the object goes out of scope.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to