cython - cdef statement not allowed here for structure -


I have a simple estrotic_jax with a straight define (astrct.pxd):

  Cdef struct A: int x int y int z  

and a Cython function that uses it (struct_test.pyx):

  random import From arctic seamport to Randink is FDET (): N = 1000000m = 65535 like I = xrange (N) in = 0 to = 0: cdef A A ax = Randint (0, M) AI = Randint (0, M ) As az = Randint (0, M). For xanded (a) i am in xrange (n): [i] as the total + =. X + like [ii] However, when I try to create struct_test.pyx, I get this error: "cdef statement is not allowed here", " Cdef aa ". It does not complain about another definition of a variable, if it is outside the loop, but I do not have much speciality about loop.   

There are different types of rules in Python and C. Cython uses the same scoping rules as for / if / while or other blocks for the entire work < This is also true for the declared variable using Code> cdef , but as you have seen, these variables should be declared at the function level and not in the sub-block.

I can think of at least two good reasons to keep this requirement:

  • It is even more obvious: the users who come with C background are in the background Do not be surprised when they do not have the scope of their variables which they can expect.
  • This means that the C code generated by Cython tracks the original Siethon code more closely, which I'm sure, makes debugging and implementing easy for Cython developers.

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -