[Pyrex] weak references to Pyrex instances?

Phillip J. Eby pje at telecommunity.com
Mon Oct 4 21:29:13 CEST 2004


At 07:46 PM 10/4/04 +0200, Jiba wrote:
>On Mon, 04 Oct 2004 10:35:25 -0400
>"Phillip J. Eby" <pje at telecommunity.com> wrote:
>
> > At 12:13 AM 10/4/04 -0400, vng1 at mac.com wrote:
> > >Hi all - what do I need to do to make a Pyrex class weak
> > >reference-able?
> >
> > Well, you can probably subclass it in Python and add:
> >
> >      __slots__ = '__weakref__'
>
>just subclassing (without adding the slot) works for me.

...and it can also add a '__dict__' attribute, that you may not need or 
want.  Using __slots__ ensures that *only* a weak reference slot is added, 
not a whole dictionary.





More information about the Pyrex mailing list