Choosing a language for writing very fast abstractions that interact with Python?

I have a system currently written in Python that can be divided into internal and external levels. Python is too slow, so I want to rewrite the backend in a quickly compiled language, preserving the Python interface so that the backend functionality is called from Python. What are the best options for this?

I was considering cython, but very limited and cumbersome to write, and not much faster. From what I remember about Boost Python for C ++, it is very annoying to maintain a bridge between languages. Is there a better choice?

My main factors:

  • execution speed
  • compilation speed
  • declarative language
+5
source share
3 answers

C ++ with SWIG can generate all the glue code you need. As long as you avoid excessive transitions between C ++ and python, this will be as fast as your C ++. SWIG interfaces are usually quite simple to generate unless you are doing something β€œweird”.

+7
source

If you used Jython, you could easily access Java back-end routines (trivially). Java is about twice as slow as c and 10x faster than python the last time I checked.

+2
source

Boost:: Python. ++ - . , .

You want to lift the heavy lift of an existing python solution into a faster language. This means that you can control the interface.

If you control the interface, you can keep it python friendly and bp friendly (IE: avoid problematic things like pointers and immutable types like l-values)

In this case, Boost :: Python might be simple, how to say which functions you want to call from python.

+1
source

All Articles