Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #91092 > unrolled thread

Re: Strategies for using cffi with C++ code?

Started byStefan Behnel <stefan_ml@behnel.de>
First post2015-05-23 05:58 +0200
Last post2015-05-23 05:58 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Strategies for using cffi with C++ code? Stefan Behnel <stefan_ml@behnel.de> - 2015-05-23 05:58 +0200

#91092 — Re: Strategies for using cffi with C++ code?

FromStefan Behnel <stefan_ml@behnel.de>
Date2015-05-23 05:58 +0200
SubjectRe: Strategies for using cffi with C++ code?
Message-ID<mailman.253.1432353504.17265.python-list@python.org>
Skip Montanaro schrieb am 22.05.2015 um 19:15:
> 2015-05-22 12:05 GMT-05:00 Lele Gaifax:
>> Maybe http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html?
> 
> Thanks for the reference, Lele. I was thinking in terms of cffi, but
> this might work as well. (Shouldn't cffi interfaces be the thinnest?)

Thin in what sense? cffi is a generic library (at least on CPython), so the
interface can never be as thin as what a dedicated compiler can generate
for a specific piece of interface code. PyPy's cffi can mitigate this by
applying runtime optimisations, but you can't do that in CPython without
running some kind of native code generator, be it a JIT compiler or a
static compiler. cffi can apply the latter (run a C compiler) to a certain
extent, but then you end up with a dependency on a C compiler at *runtime*.
The term "thin" really doesn't apply to that dependency. And even if you
accept to go down that route, you'd still get better results from runtime
compilation with Cython, as it will additionally optimise your interface
code (and thus make it "thinner").

Being a Cython core developer, I'm certainly a somewhat biased expert, but
using Cython to generate a statically compiled and optimised C++ wrapper is
really your best choice. IMHO, it provides the best results/tradeoffs in
terms of developer effort, runtime performance and overall end user experience.

Stefan

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web