开发者

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 kee开发者_开发知识库ping 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


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


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.


I would disagree about Boost::Python. It can get cumbersome when wrapping an existing c++-centric library and trying not to change the interface. But that is not what you are looking to do.

You are looking to push the heavy lifting of an existing python solution in to a faster language. That means that you can control the interface.

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

In that case, Boost::Python can be as simple as telling it which functions you want to call from python.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜