[Cython] Problem with cdef long
Simon King
king at mathematik.uni-jena.de
Mon Jun 2 21:51:31 CEST 2008
Dear Cython team,
hopefully the following really is a cython-question, not a Sage-question.
Write a file Problem.pyx:
ctypedef struct Term_t:
long coef
cdef class Term:
cdef Term_t Data
def __init__(self, c):
self.Data.coef = c
def coefficient(self):
return self.Data.coef
Start Sage and do
sage: attach Problem.pyx
sage: T=Term(3)
sage: type(T.coefficient())
Then the result is
<type 'int'>
and *not* <type 'long'>!
Why is it of type 'int' although coef is defined 'long' in Term_t? How can
i avoid this automatic down-grading of coef?
I really want coef to be of type 'long', since 'int' isn't good enough in
my application.
Yours
Simon
More information about the Cython-dev
mailing list