[Cython] [cython-users] Recommendations for efficient typed arrays in Cython?

Sturla Molden sturla at molden.no
Thu Jan 31 21:31:49 CET 2013


On 29.01.2013 22:15, Sal wrote:

> I don't have any 'typical' Python code yet, everything is 'cdef' type
> stuff, but reference counting is still performed by Cython on 'cdef'
> types, so sticking them into a C++ array probably ignores that fact.

I think the main difficulty with Cython (for beginners at least) is 
knowing 'when we are in C land' and 'when we are in Python land'. I 
think this is the fundamental problem you are facing here.

I therefore think it is is unfortunate that we write

   cdef object a
   cdef list b
   cdef foobar c

etc to define Python variables. 'cdef' seems to indicate that it is a C 
declaration, yet here it is not.

Neither does this cdef syntax allow us to declare Python int and float 
statically.

Perhaps it would be easier if Python variables were declared with 
'pydef'? Or perhaps just 'def'?

Then it might be easier to see what is Python and what is C.


Sturla






More information about the cython-devel mailing list