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


Groups > comp.lang.python > #91092

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

Path csiph.com!usenet.pasdenom.info!news.albasani.net!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'static': 0.03; 'compiler': 0.05; 'cpython': 0.05; 'dependency': 0.07; 'statically': 0.07; 'subject:code': 0.07; 'wrapper': 0.07; 'additionally': 0.09; 'compiler.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'runtime': 0.09; 'subject:using': 0.09; '(at': 0.13; 'expert,': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'gmt-05:00': 0.16; 'optimised': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'route,': 0.16; 'developer': 0.16; 'compilation': 0.18; 'developer,': 0.18; 'skip': 0.18; 'stefan': 0.18; 'library': 0.20; 'latter': 0.22; 'code.': 0.23; 'interfaces': 0.23; 'header:In- Reply-To:1': 0.24; 'thus': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'least': 0.27; "doesn't": 0.28; "i'm": 0.29; 'interface': 0.29; 'piece': 0.29; 'certainly': 0.31; 'maybe': 0.31; 'certain': 0.31; 'code': 0.31; "can't": 0.32; 'core': 0.32; 'compiled': 0.32; 'subject:?': 0.34; 'running': 0.34; 'to:addr:python-list': 0.35; 'c++': 0.35; 'generic': 0.35; 'really': 0.35; 'but': 0.36; 'being': 0.36; 'url:org': 0.36; 'thanks': 0.36; '(and': 0.36; 'subject:: ': 0.37; 'received:org': 0.38; 'end': 0.39; 'performance': 0.39; 'url:docs': 0.39; 'to:addr:python.org': 0.39; 'well.': 0.40; 'subject:with': 0.40; 'received:de': 0.40; 'some': 0.40; 'term': 0.60; 'your': 0.60; 'even': 0.61; 'experience.': 0.64; 'results': 0.66; 'overall': 0.70; 'applying': 0.73; 'subject:Strategies': 0.91; 'choice.': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Stefan Behnel <stefan_ml@behnel.de>
Subject Re: Strategies for using cffi with C++ code?
Date Sat, 23 May 2015 05:58:10 +0200
References <skip.montanaro@gmail.com> <CANc-5UyK4+jAxZ_WDnEbM7RgAQk=k2uKJs8a=m1phGeb8DfAYQ@mail.gmail.com> <201505211706.t4LH6GY0006031@fido.openend.se> <CANc-5UyBC-vw_+Og-1gea9YXubpATezsOmNf58AKKgb0swBP9A@mail.gmail.com> <87oalclf0d.fsf@nautilus.nautilus> <CANc-5UwsOTUvMCnZ_vi3nqu6O2sCPqkAwCHY=aEiT+qY-iLdQQ@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host dslb-088-067-180-119.088.067.pools.vodafone-ip.de
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0
In-Reply-To <CANc-5UwsOTUvMCnZ_vi3nqu6O2sCPqkAwCHY=aEiT+qY-iLdQQ@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.253.1432353504.17265.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1432353504 news.xs4all.nl 2954 [2001:888:2000:d::a6]:53209
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:91092

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web