On Jul 3, 5:34 am, Jack Diederich wrote:
> On Thu, Jul 2, 2009 at 2:36 PM, Carl Banks wrote:
> > Warning: objects with a __del__ attribute prevent reference cycle
> > detection, which can potentially lead to memory (and resource) leaks.
> > So you must be careful to avoid creating reference loops
In article ,
Tim Roberts wrote:
>Dave Angel wrote:
>>
>>You're right of course. What I was trying to say was it deletes the
>>reference to the object. Unlike obj = None, del obj removes the
>>reference (attribute) entirely. Although I don't know what it should be
>>called if it's a local
Dave Angel wrote:
>
>You're right of course. What I was trying to say was it deletes the
>reference to the object. Unlike obj = None, del obj removes the
>reference (attribute) entirely. Although I don't know what it should be
>called if it's a local variable. Perhaps it "unbinds" the nam
On Thu, Jul 2, 2009 at 2:36 PM, Carl Banks wrote:
> On Jul 2, 3:12 am, Ulrich Eckhardt wrote:
>> Bearophile wrote:
>> > Ulrich Eckhardt:
>> >> a way to automatically release the resource, something
>> >> which I would do in the destructor in C++.
>>
>> > Is this helpful?
>> >http://effbot.org/pyre
Thanks to all that answered, in particular I wasn't aware of the existence
of the __del__ function.
For completeness' sake, I think I have found another way to not really solve
but at least circumvent the problem: weak references. If I understand
correctly, those would allow me to pass out handles
> You can go ahead and implement a __del__() method. It will often work in
> CPython, but you get no guarantees, especially when you have reference
> cycles and with other Python implementations that don't use refcounting.
And for resources whose lifetime is greater than your process (e.g. a
file)
Peter Otten schreef:
> Ulrich Eckhardt wrote:
>
>> Bearophile wrote:
>>> Ulrich Eckhardt:
a way to automatically release the resource, something
which I would do in the destructor in C++.
>>> Is this helpful?
>>> http://effbot.org/pyref/with.htm
>> Yes, it aims in the same direction. How
On Jul 2, 3:12 am, Ulrich Eckhardt wrote:
> Bearophile wrote:
> > Ulrich Eckhardt:
> >> a way to automatically release the resource, something
> >> which I would do in the destructor in C++.
>
> > Is this helpful?
> >http://effbot.org/pyref/with.htm
>
> Yes, it aims in the same direction. However,
Christian Heimes wrote:
Dave Angel wrote:
Look also at 'del' a command in the language which explicitly deletes an
object.
No, you are either explaining it the wrong way or you have been fallen
for a common misinterpretation of the del statement. The del statement
only removes the obje
Dave Angel wrote:
> But I'm guessing you want something that automatically deletes objects
> whenever the last reference disappears. That's an implementation
> detail, not a language guarantee. In particular CPython does what you
> want, by using reference counting. That's the only Python I've
Dave Angel wrote:
> Look also at 'del' a command in the language which explicitly deletes an
> object.
No, you are either explaining it the wrong way or you have been fallen
for a common misinterpretation of the del statement. The del statement
only removes the object from the current scope. This
Ulrich Eckhardt wrote:
Hi!
I'm currently converting my bioware to handle Python code and I have
stumbled across a problem...
Simple scenario: I have a handle to a resource. This handle allows me to
manipulate the resource in various ways and it also represents ownership.
Now, when I put this in
Ulrich Eckhardt wrote:
> Bearophile wrote:
>> Ulrich Eckhardt:
>>> a way to automatically release the resource, something
>>> which I would do in the destructor in C++.
>>
>> Is this helpful?
>> http://effbot.org/pyref/with.htm
>
> Yes, it aims in the same direction. However, I'm not sure this a
Bearophile wrote:
> Ulrich Eckhardt:
>> a way to automatically release the resource, something
>> which I would do in the destructor in C++.
>
> Is this helpful?
> http://effbot.org/pyref/with.htm
Yes, it aims in the same direction. However, I'm not sure this applies to my
case. The point is that
Ulrich Eckhardt:
> a way to automatically release the resource, something
> which I would do in the destructor in C++.
Is this helpful?
http://effbot.org/pyref/with.htm
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
Hi!
I'm currently converting my bioware to handle Python code and I have
stumbled across a problem...
Simple scenario: I have a handle to a resource. This handle allows me to
manipulate the resource in various ways and it also represents ownership.
Now, when I put this into a class, instances to
16 matches
Mail list logo