[Pyrex] exposing extension class attributes
Greg Ewing
greg.ewing at canterbury.ac.nz
Wed Mar 19 01:04:09 CET 2008
Simon Burton wrote:
> Ie. the c attribute has an underscore in front of it, and
> from python the attribute is without underscore.
>
> As this is likely to drive me moderately crazy (keeping track
> of underscores) I am wondering how other people handle this issue ?
Would calling it "c_foo" make you feel any better?
I'm not sure what could be done to make this any easier,
short of having some magic by which the same name refers
to the C attribute in Pyrex and the Python property in
Python. But you need to be able to refer to the property
in Pyrex as well, so I can't see how that would work.
> A similar problem occurs with methods. I gave up on duplicating every method
> (a cdef version and a python version), and am just using python methods for now.
Cython has a mechanism for making C methods callable from
Python as well as Pyrex, but last I heard, the implementation
is incorrect in the presence of overriding+inheritance, and
the Cython people are unwilling to pay the performance cost
required to make it work properly.
Some version of this may appear in Pyrex eventually, when
I figure out how to implement it correctly. In the meantime,
I'm using "c_" prefixes to keep my Python and C methods
sorted out.
--
Greg
More information about the Pyrex
mailing list