[Pyrex] 'cdef'ed methods are always static?

Eric Huss e-huss at netmeridian.com
Tue Feb 21 20:26:56 CET 2006


It would help if you posted the error message you got.  I get this when
compiling:

x.pyx:17:14: Cannot convert 'int ((int ))' to Python object

Pyrex does not infer the type of an object.  Since "cdef" methods are not
directly accessible through standard Python mechanisms, you need to tell
Pyrex the type of object you have so that it knows it can directly call
the "cdef" method.  Add a type declaration for your local variable in the
call_Key function like this:

def call_Key(int parm):
  cdef IT ITC

-Eric

On Tue, 21 Feb 2006, Helmut Jarausch wrote:

> Hi
>
> is this a bug in Pyrex ?
>
> cdef int Key(int x):
>   return 3*x
>
> cdef class IT:
>   cdef int (*Fct)(int)
>   def __new__(self): pass
>   cdef void set_Fct(self,int (*FPtr)(int)):
>     self.Fct= FPtr
>
>   def display(self,int count):
>     print "Key=",self.Fct(count)
>
> def call_Key(int parm):
>   ITC=IT()
>   IT.set_Fct(ITC,Key)   # This works just fine
> #  ITC.set_Fct(Key)     # This doesn't work     <=====
>   ITC.display(parm)
>
> Test by the script
>
> #!/usr/local/bin/python
> import CallTest
>
> CallTest.call_Key(7)
>
>
> Many thanks for your help,
> Helmut
>
> --
> Helmut Jarausch
>
> Lehrstuhl fuer Numerische Mathematik
> RWTH - Aachen University
> D 52056 Aachen, Germany
>
> _______________________________________________
> Pyrex mailing list
> Pyrex at lists.copyleft.no
> http://lists.copyleft.no/mailman/listinfo/pyrex
>



More information about the Pyrex mailing list