ANN.: Beta 1.0 of Weak Reference Extension Module is now available

shindich at my-deja.com shindich at my-deja.com
Wed Nov 15 22:18:48 EST 2000


In article <mtaeb1f4q3.fsf at astron.berkeley.edu>,
  johann at physics.berkeley.edu wrote:
> shindich  writes:
>
> > Tired of cercular references?
> > Use weak references! http://PyWeakReference.sourceforge.net/
>
> Looks neat!  But maybe you could answer me a quick question, since I
> really don't understand weak references.
>
> I can see how they are useful if you only have reference counting, but
> is there any need for them if you have real garbage collection?  If
> not, why does Java have them?
>
> --J
>
> --
> Johann Hibschman                           johann at physics.berkeley.edu
>
I suspect of two reasons for why Java has weak references:
1. Tracking down circular references is very expensive even for real
garbage collectors. Therefore, you might get better performance if you
use weak references instead of creating circular references.
2. The other reason is philosophical. You might have cases where your
client code cannot control the lifetime of the referenced object. A
weak reference represents sort of an entry in a DMV registry. The DMV
has everyone’s address, but the database is never up to date.
Therefore, it is possible that the person the DMV is trying to contact
has either moved or, God forbid, died. In that case, DMV's letter will
be returned back.  (I hope my example makes sense...)

Regards,

Alex Shindich
Visit http://www.shindich.com/


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list