What is the motive behind developing Python bindings for existing code in other languages? I see many programmers developing Python bindings for their existing C code. Why? How does it help?
-
5... by allowing them to be used in Python without having to totally rewrite them? – obataku Aug 08 '12 at 04:14
3 Answers
Although I cannot say this with full authority because it is preference-based, developing Python bindings for C makes development process easier for those who find Python syntax more productive and easier to work with.
(for example, Python CUDA, 3D, Kinect, etc. libraries)

- 4,752
- 4
- 32
- 42
-
I guess development of wrappers(bindings) is also done in Java. Does Python bindings have any advantage over them ? What criterion makes us decide to go for python binding or java wrapper ? Thanks. – N mol Aug 13 '12 at 13:33
-
1I think it is subjective. Some, including myself, find Python extremely easy and productive to program. (executable pseudocode), and I think this is the motivation of most. I am Java programmer as well, so it is hard for me to bash language I continuosly used for 16 years, but if I am to choose a binding it would be in Python. Right now I am developing one for Accumulo API. – Edmon Aug 13 '12 at 14:21
Python has bindings in C, because C is a low-level language that can be very fast and effective, while providing support for a huge amount of hardware and software capabilities. C is very difficult for beginners and inherently lacks object-oriented features, which Python improves upon. C's lack of object-oriented behaviour also contributed to the creation of C++.
Frequently, software projects are bounded by the speed of the developer and not the execution speed of the code, where Python excels over C, in most cases.
Python's strengths over C include:
- very clear, readable syntax
- strong introspection capabilities
- intuitive object orientation
- natural expression of procedural code
- full modularity, supporting hierarchical packages
- exception-based error handling
- very high level dynamic data types
- extensive standard libraries and third party modules for virtually every task
- extensions and modules easily written in C, C++ (or Java for Jython, or .NET languages for IronPython)
- embeddable within applications as a scripting interface

- 37,233
- 13
- 109
- 109
-
The statement "Python is interpreted into C" is misleading at best. The most common implementation of Python is indeed an interpreter written in C, but Python code is never transformed in any way into C, and other implementations (PyPy, Jython, IronPython) use other strategies. – Danica Aug 08 '12 at 04:19
-
I guess development of wrappers(bindings) is also done in Java. Does Python bindings have any advantage over them ? What criterion makes us decide to go for python binding or java wrapper ? Thanks. – N mol Aug 12 '12 at 19:59
Because there are many very high quality libraries in C with many many years of testing, bugfixing, etc., and it is crazy to try to reimplement everything in Python (e.g., I would never use cryptographic libraries in Python, one should use bindings to well tested and paranoid-developed C libraries like openssl, NSS, or gnutls).

- 2,688
- 1
- 23
- 38