Please explain the meaning of 'stealing' a ref

Michael Hudson mwh at python.net
Tue Nov 4 07:32:22 EST 2003


Christos "TZOTZIOY" Georgiou <tzot at sil-tec.gr> writes:

> I invested some time today because I got this crazy idea that if I
> implemented a simple attribute-getting caching scheme implemented in
> PyObject_GetAttr / PyObject_SetAttr that would turn out to be good.

Are you aware of the cache-attr-branch (think it's called that) in
CVS?

> So I did implement one touching Objects/object.c (and pythonrun.c for
> init/final purposes), and I got a 5% increase in pystone... of course,
> when I exited the interpreter, I got a nice segfault :-)  Also,
> test.testall segfaulted at test_anydbm.  I didn't expect anything
> better, to be honest; it's obviously got something to do with inc/dec
> refs.
> 
> Now I'm googling for the various debug building options (I'm not sure
> that -DDEBUG is enough etc), however I realised it's time to ask what I
> never understood so far: what exactly is the meaning of a function
> "stealing a reference"?  Is it that the function does an incref or a
> decref?  Or is it something more obscure?

This *really* should be explain in the API reference or the extended
and embedding manual somewhere... have you looked there?

Cheers,
mwh

-- 
  There are two ways of constructing a software design: one way is to
  make it so simple that there  are obviously no deficiencies and the
  other way  is to make it so complicated  that there are  no obvious
  deficiencies.                                      -- C. A. R. Hoare




More information about the Python-list mailing list