[pypy-dev] sprint report

Armin Rigo arigo at tunes.org
Fri Jul 20 14:48:17 CEST 2007

Hi all,

As Laura and Jacob already hinted at, Laura and me managed to write
three times and trash twice code that allows ll external functions to be
really called on top of CPython.  This means that code can now be
written using rffi, including calls to external functions, and this can
be tested on top of CPython.  We have thus a ctypes replacement, from
the point of the view of the CPython user; and we no longer need rctypes
at all from the point of the view of the RPython user.

Our code (in ll2ctypes.py) is able to transparently convert structures
created by lltype.malloc(TYPE, flavor='raw') so that their storage
becomes a ctypes object internally.  This is done lazily, when the
structure "escapes" to a call to an external function.  The call itself
is also performed through ctypes.  As usual we had to fight a bit with
ctypes to have it do what we really need (instead of what it thinks
you'd prefer today) but nothing deep (Jacob's mail seems to say that we
were blocked unless we rewrote ctypes - I'm not sure what he refers to).

This is a no-API piece of code invoked automatically when an lltype
pointer to an external function is called on top of CPython.

A few new pieces of API have been added to rffi.py for general rffi
usage, notably rffi.cast(TARGETTYPE, value) which tries to have the same
semantics as the C-level cast operator.

A bientot,


More information about the Pypy-dev mailing list