[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lua vs Python C bindings
- From: Dibyendu Majumdar <mobile@...>
- Date: Sun, 23 Jun 2019 00:39:02 +0100
Recently I started created a Python binding for one of my projects. I
already had Ravi/Lua bindings hand-coded in C++/C.
With regards to the C api of Python vs Lua there is no contest. The
Python C api is much more verbose and hence writing a binding in that
is a big task.
But what surprised me is a tool called Cython.
It accepts an extended Python syntax, where you can statically declare
C and C++ types, and then use them in the Python code. Then you run
the Cython compiler and it generates C or C++ code and that's it.
Basically you write Python like high level language most of the time,
and everything else is taken care of. Ref counting, type checking, all
taken care of.
Amazingly it works with C++ too as my project is in C++. No need to
write C wrappers.
So it seems that writing a C/C++ binding for Python is actually less
effort than writing one for Lua.
It seems like creating a Cython clone for Lua might be a good idea.
Maybe someone is already doing this?
Regards
Dibyendu