[pypy-dev] cpyext reference counting and other gc's

Amaury Forgeot d'Arc amauryfa at gmail.com
Sat Mar 26 09:33:45 CET 2011


Hi,

2011/3/26 Dima Tisnek <dimaqq at gmail.com>:
> Hey, I had a look at cpyext recently and saw that reference counting
> is emulated with, err, reference counting, seeminlgy in the referenced
> object itself.
>
> Does this mean that cpyext would not work with other gc's or is there
> some wrapping going on behind the scenes?

Cpyext works with all pypy gc's. The PyObject* exposed to C code is actually
a proxy to the "real" interpreter object; a dict lookup is necessary each time a
reference crosses the C/pypy boundary. Yes, this is slow.

This is implemented in pypy/module/cpyext/pyobject.py; the main functions are
create_ref() and from_ref().

-- 
Amaury Forgeot d'Arc



More information about the Pypy-dev mailing list