> This works for me:
>
> import cython
>
> @cython.locals(x=int, y=cython.p_int)
> def foo(x):
>     y = cython.address(x)
>     print x + cython.sizeof(y) + cython.sizeof(cython.p_int)
>     print cython.compiled
>
> foo(34)

Wow, this works too for me (I was trying that xx case above). This is
what I get with pure python:

36
False

and cythonized:

42
True

> Exactly how to do this with decorators (and/or automatically) is less
> clear (syntax-wise, and there are more technical issues about
> signatures matching, etc.). What you can do is write an
> accompanying .pxd file which will, of course, be ignored by Python,
> but can declare cdef classes/methods/etc for Cython. Then your class
> and def statements will be appropriately coerced when you compile.

This brings me the idea, why not to just take the current syntax and
just generate a pure Python one from it? That way one also needs to
maintain just one codebase, only it will by the Cython one, but it
could always be used in Pure python.

For some reason I prefer the pure python syntax approach though.

Ondrej
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to