[Python-Dev] Free threading and borrowing references from mutable types

Guido van Rossum guido@python.org
Wed, 12 Sep 2001 09:43:56 -0400


> [Guido]
> > ...
> > Because it returns a borrowed value, PyDict_GetItem can't safely be
> > fixed to check for this and call the __getitem__ slot.

[Tim]
> If PyDict_GetItem ended up calling a non-genuine-dict __getitem__ slot, what
> would stop it from decref'ing the result in that case before returning it
> (thus returning a borrowed reference even so)?  That __getitem__ may
> synthesize a result object with a refcount of 1?

Exactly.

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