[Cython] Type casts

Robert Bradshaw robertwb at math.washington.edu
Sat Feb 2 01:12:49 CET 2008


Currently, in Cython, when x is a python object, <int>x gives the  
address of x. This is counter-intuitive and rarely useful. (When it  
is, one can always do <size_t><void *>x).

I would propose making <type>x do a conversion (the same as cdef type  
y = x would) whenever type is a non-object type and x isn't, or vica- 
versa. Between C types it already behaves this way, and between  
Python objects it already has special meaning.

I would also propose something like

<ExtensionType?>x to be a cast into type ExtensionType *with* type  
checking.

Thoughts?

- Robert



More information about the Cython-dev mailing list