I polished off some more of the pure python mode stuff tonight. I  
just pushed it to cython-devel. Now you can do stuff like:

> import cython  # you need a single file to be in your path to use  
> it in pure Python mode, provided (and installed) with Cython
>
> @cython.locals(x=int, y=cython.p_int)
> def foo(x):
>     y = cython.cast(cython.p_int, x)
>     print x + cython.sizeof(y) + cython.sizeof(cython.p_int)
>     if cython.compiled:
>         print "the compiler was run
>     else:
>         print "just being interpreted"
>
> x = cython.declare(int)
> xx = cython.declare(cython.p_int)
> xx = cython.address(x)
>
> MyStruct = cython.struct(x=int, y=int, data=cython.pp_double)
>
> a = cython.declare(MyStruct)
> a.x = 5
>
> T = cython.typedef(MyStruct)
> b = cython.declare(cython.pointer(T))
> b[0].x = 4


On top of this, you can write a .pxd file to accompany your .py file  
and it will coerce your .py file classes and def statements into cdef  
and cpdef versions.

It's still very new and probably highly experimental (though it only  
modifies the cython.* nodes, so it shouldn't cause any regressions).  
Let me know what you think.

- Robert

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

Reply via email to