[Cython] Hello

John Skaller2 skaller at internode.on.net
Mon Jan 27 20:07:09 EST 2020



> On 27 Jan 2020, at 20:23, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> 
> On 27/01/20 6:56 pm, John Skaller2 wrote:
>> Felix binds C/C++ code with statements like:
>> 	type PyObject = “PyObject*”;
>> 	fun add: PyObject * PyObject -> PyObject = “Py_AddLong($1)”;
>> and can use the bindings like:
>> 	
>> 	var a : PyObject = ….
>> 	var b: PyObject = ...
>> 	var sum = add (a,b);
> 
> How does it deal with reference counting and exception handling?

The Felix binding generates C. So the answer is, the same way as you would in C.

However the above is a low level binding, one to one with C. 
Higher level stuff is possible. Won’t know until the binding is operational.
My script is basically working translating the *.pxd files in Cython.
(Just the functions, the rest can be done by hand).

Basically I can write, say, a concurrent matrix multiplication routine and
map it to Python. Of course you can do that in C as well, but Felix is a very
high level language so you can do stuff you wouldn’t bother attempting
in low level languages like C and C++.

—
John Skaller
skaller at internode.on.net







More information about the cython-devel mailing list