[Python-Dev] Quick-and-dirty weak references

Guido van Rossum guido@CNRI.Reston.VA.US
Fri, 20 Aug 1999 11:09:32 -0400

> In reply to no one in particular:
>  I've often wished that the instance type object had an (optimized) 
> __decref__ slot. With nothing but hand-waving to support it, I'll 
> claim that would enable all these games.

Without context, I don't know when this would be called.  If you want
this called on all DECREFs (regardless of the refcount value), realize
that this is a huge slowdown because it would mean the DECREF macro
has to inspect the type object, which means several indirections.
This would slow down *every* DECREF operation, not just those on
instances with a __decref__ slot, because the DECREF macro doesn't
know the type of the object!

--Guido van Rossum (home page: http://www.python.org/~guido/)