[Cython] initialised cdef class variables
Robert Bradshaw
robertwb at math.washington.edu
Tue Jun 17 07:59:15 CEST 2008
On Jun 16, 2008, at 7:35 PM, David McNab wrote:
> Hi,
>
> I've been trying to convert my 'PyGene' genetic programming/algorithms
> package to Cython, and have hit a major obstacle.
>
> With PyGene, configuration is largely done by subclassing and
> overriding
> class attributes.
>
> But with Cython(/Pyrex), this doesn't seem to be possible. If, in a
> cdef
> class, I declare writable class attributes with initialisers, such as:
>
> cdef class Foo:
>
> cdef int bar = 5
>
> the class attribute 'bar' is not getting initialised.
>
> Would it be possible to have class attribute initialiser support in a
> future release of Cython?
Yes, we should support this. (Note that this will not be a class-
level cdef attribute however, it would just change the initial value
for the instance member) Please file a report at http://
trac.cython.org/cython_trac/ .
- Robert
More information about the Cython-dev
mailing list