[Python-ideas] Why CPython is still behind in performance for some widely used patterns ?
Antoine Pitrou
solipsis at pitrou.net
Tue Feb 20 01:17:26 EST 2018
On Mon, 19 Feb 2018 20:15:27 +0100
Stefan Behnel <stefan_ml at behnel.de> wrote:
> Nick Coghlan schrieb am 02.02.2018 um 06:47:
> > to make the various extension module authoring tools
> > easier to discover, rather than having folks assuming that handcrafted
> > calls directly into the CPython C API is their only option.
>
> Or even a competitive option. Tools like Cython or pybind11 go to great
> length to shave off every bit of overhead from C-API calls, commonly
> replacing high-level C-API functionality with macros and direct access to
> data structures. The C/C++ code that they generate is so complex and tuned
> that it would be infeasible to write and maintain something like that by
> hand, but it can perfectly be generated, and it usually performs visibly
> better than most hand-written modules, definitely much better than anything
> a non-expert could write.
>
> Basically, by not learning the C-API you can benefit from all that highly
> tuned and specialised code written by C-API experts that the documentation
> doesn't even tell you about.
Doesn't the documentation ever mention Cython? It probably should (no
idea about pybind11, which I've never played with). Perhaps you can
open an issue about that?
As a sidenote, you can certainly use Cython without learning the C API,
but to extract maximum performance it's better to know the C API
anyway, to be aware of what kind of optimizations are available in
which situations.
Regards
Antoine.
More information about the Python-ideas
mailing list