ANN: mxProxy Package - Version 0.2.0

M.-A. Lemburg mal at lemburg.com
Fri Aug 20 03:45:21 EDT 1999


Neil Schemenauer wrote:
> 
> M.-A. Lemburg <mal at lemburg.com> wrote:
> >2. using a weak reference which allows you to build circular
> >   reference models in your data without producing the other-
> >   wise difficult to handle memory leakage induced by this.
> 
> This is an interesting implementation of weak references.
> Thanks.  Attached is a weak reference implementation I cooked up
> yesterday.  It is more of a hack then your approach but has the
> advantage that referenced objects die sooner.  Unfortunately, my
> proxy object is incomplete.

You have an interesting implementation there too :-) Both ways
have their merrit I guess. The problem with your idea is that
you need setattr() to work on the object -- this doesn't work
on builtin types, but does do the trick for all Python instances.
My implementation builds on a true proxy that also covers
builtin types (because it also handles type slots, well, at least
most of them: the numeric slots don't work yet because of coercion
issues) and has the advantage of not modifying the referenced
object at all.

Jack Janssen just recently suggested adding a weak bit flag
to all Python objects. This would in the end cause all objects
to grow by about 2-4 bytes depending on struct alignment. With this
flag one could do much the same as suggest in your approach
(using an additional global dict like I do). However the amount
of extra storage needed is significant and probably not even
used in most cases, so the weak bit idea is controversial.

BTW, calling the checkweakrefs() function in mxProxy is pretty
much equivalent to explicitly invoking the GC in JPython.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Y2000:                                                   133 days left
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/






More information about the Python-list mailing list