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

Tim Peters tim.one@home.com
Wed, 12 Sep 2001 01:52:37 -0400


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

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?

hard-to-approve-of-users<wink>-ly y'rs  - tim