[Python-ideas] discouraging direct use of the C-API

Caleb Hattingh caleb.hattingh at gmail.com
Thu May 7 13:58:01 CEST 2015


> On 7 May 2015, at 9:50 pm, Paul Moore <p.f.moore at gmail.com> wrote:
> 
> On 7 May 2015 at 10:11, Stefan Krah <stefan at bytereef.org> wrote:
>> Caleb Hattingh <caleb.hattingh at ...> writes:
>>>> -1. CFFI is much slower than using the C-API directly.
>>> 
>>> I am quite interested in this; do you happen have a link to a case
>> study/gist/repo where this has been
>>> measured? Even if you can remember people’s names involved or something
>> similar, I could google it myself.
>> 
>> I've measured it here:
>> 
>> https://mail.python.org/pipermail/python-dev/2013-December/130772.html
>> 
>> CFFI is very nice (superb API), but not for high performance use cases.
> 
> I'm guessing that benchmark used cffi in the "ABI level" dynamic form
> that matches ctypes. Did you try the cffi "API level" form that
> creates a C extension? I'd be curious as to where that falls in
> performance.

I had a quick look around, @eevee made this comparison some time ago:

===
 	• CPython 2.7 + Cython: 2.0s
	• CPython 2.7 + CFFI: 2.7s
	• PyPy 2.1 + CFFI: 4.3s
That’s the time it takes, from a warm start, to run the test suite.
===

from http://eev.ee/blog/2013/09/13/cython-versus-cffi/

Kind regards
Caleb


More information about the Python-ideas mailing list