[Pyrex] exposing extension class attributes

Simon Burton simon at arrowtheory.com
Tue Mar 18 18:55:57 CET 2008


I am considering using some kind of name convention to distinguish between
extension class access at the python and at the c level:

cdef class Foo:

    cdef int _foo

    def __init__(self, int foo):
        self._foo = foo

    property foo:
        def __get__(self):
            return self._foo


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 ?

I guess I am just trying to write C code without writing C code (or C++ code).
Perhaps I can abandon (exposing these classes to) the python interpreter altogether, 
and stick to writing pyrex code.

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.

What am I doing ? I hear java is a good language. Easy to hire java programmers.

FWIW i just finished a 12 month development cycle using rpython to do similar things.
It is interesting comparing the two approaches. Pyrex is a much more mature and useable 
tool, but rpython is a lot of fun too.

Simon.






More information about the Pyrex mailing list