Why are Python bindings developed for existing code in other languages such as C?

536 views Asked by At

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?

3

There are 3 answers

2
Alex W On BEST ANSWER

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

http://www.python.org/about/

2
Edmon On

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)

0
mcepl On

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).