[SciPy-Dev] GSoC'21 Blog: Improve performance through use of Pythran

Ralf Gommers ralf.gommers at gmail.com
Tue Aug 31 05:51:29 EDT 2021


On Tue, Aug 31, 2021 at 11:10 AM Pamphile Roy <roy.pamphile at gmail.com>
wrote:

> Great job Xingyu! And happy to read that you are planning to contribute
> more.
>
> > On 30.08.2021, at 20:37, Ralf Gommers <ralf.gommers at gmail.com> wrote:
> >
> > One of the main take-aways we learned recently was that we should use
> Pythran to accelerate the private part of a function, but leave the public
> signature and input validation in Python. This is something that wasn't
> obvious at the start of Xingyu's project, and we'll need to make sure we do
> that also for already-merged PRs (for consistently, and possibly to fix
> some undetected corner case bugs in master) before branching off 1.8.x.
> Other than that I think we are still pretty happy with Pythran; it gives us
> fast performance that's easier to obtain than with Cython.
>
> Ok, then I understand from this that we should do Pythran over Cython for
> new code.
>

It's not as simple as that, it depends on what you're trying to do. If
Pythran fits, like for individual kernels, then probably yes. Cython can do
more complex things though, like interact with the Python and NumPy C APIs,
threading, etc. Serge and I gave a talk at SciPy'21 that addresses this:
https://www.youtube.com/watch?v=6a9D9WL6ZjQ&t=2s.


> Just a thought. If we are going this road, it looks like we could have a
> Python API and a Pythran/(Cython) API. A user could then decide to skip the
> validation like that.
> Having the same signature would be less of a work in terms of doc as we
> could just add a note in the Python function about the existence of a
> Pythran version.
> Or we allow differences and clearly state that this API is not as strict
> as the Python API.
>

There's no such thing as a Pythran API. Pythran generates a Python API, and
there's no separate C-like API. So whether a Python function uses Pythran
under the hood should always be an implementation detail. It is unrelated
to potentially skipping validation.

Cheers,
Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/scipy-dev/attachments/20210831/7fb10071/attachment.html>


More information about the SciPy-Dev mailing list