Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Language choices for writing very fast abstractions interfacing with Python?

I have a system currently written in Python that can be separated into backend and frontend layers. Python is too slow, so I want to rewrite the backend in a fast compiled language while keeping the frontend in Python, in a way that lets the backend functionality be called from Python. What are the best choices to do so?

I've considered cython but it's very limited and cumbersome to write, and not that much faster. From what I remember of Boost Python for C++, it's very annoying to maintain the bridge between languages. Are there better choices?

My main factors are:

  • speed of execution
  • speed of compilation
  • language is declarative
like image 712
Heinrich Schmetterling Avatar asked Nov 15 '10 19:11

Heinrich Schmetterling


2 Answers

C++ with SWIG can generate all of the glue code you need. So long as you avoid excessive jumps between C++ and python it'll be as fast as your C++. SWIG interfaces are usually fairly straightforward to generate unless you're doing something "odd".

like image 164
Flexo Avatar answered Nov 14 '22 22:11

Flexo


If you used Jython you could call into Java back-end routines easily (trivially). Java's about twice as slow as c and 10x faster than python last time I checked.

like image 21
Bill K Avatar answered Nov 14 '22 23:11

Bill K