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

2013-02-01 Thread Sturla Molden

On 01.02.2013 01:11, Greg Ewing wrote:


Without the cdef, these variables would be stored wherever Python
normally stores variables for the relevant scope, which could be
in a module or instance dict, and the usual Python/C API machinery
is used to access them.



Distinguishing between Python and C types would be problematic
anyway, since a PyObject* is both a Python type *and* a C type.


Really?

The way I see it, "object" is a Python type and "PyObject*" is a C type. 
That is, PyObject* is just a raw C pointer with respect to behavior.



Sturla
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


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

2013-02-01 Thread Greg Ewing

Sturla Molden wrote:
The way I see it, "object" is a Python type and "PyObject*" is a C type. 
That is, PyObject* is just a raw C pointer with respect to behavior.


Well... while it's possible to declare something as PyObject*
in Cython and get raw pointer behaviour, it's something you
should only do in very rare circumstances, because you're
then totally on your own when it comes to reference counting
and exception handling.

If you're suggesting that 'def object foo' should give Python
reference semantics and 'cdef object foo' raw C pointer
semantics, that would lead to a world of pain.

--
Greg
___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel