[Python-Dev] PEP 579 and PEP 580: refactoring C functions and methods

INADA Naoki songofacandy at gmail.com
Sat Jul 7 04:08:21 EDT 2018


On Sat, Jul 7, 2018 at 4:35 PM Stefan Behnel <stefan_ml at behnel.de> wrote:
>
> INADA Naoki schrieb am 07.07.2018 um 06:10:
> > How often "custom method type" are used?
> >
> > I thought Cython use it by default.
> > But when I read code generated by Cython, I can't find it.
> > It uses normal PyMethodDef and tp_methods.
> >
> > I found CyFunction in Cython repository, but I can't find
> > how to use it.  Cython document doesn't explain any information
> > about it.
>
> Its usage is disabled by default because of some of the problems that
> Jeroen addresses in his PEP(s).
>
> You can enable Cython's own function type by setting the compiler directive
> "binding=True", e.g. from your setup.py or in a comment at the very top of
> your source file:
>
>     # cython: binding=True
>
> The directive name "binding" stems from the fact that CyFunctions bind as
> methods when put into classes, but it's really misleading these days
> because the main advantage is that it makes Cython compiled functions look
> and behave much more like Python functions, including introspection etc.
>
> Stefan
>

Thank you.  Do you plan to make it default when PEP 580 is accepted
and implemented?

Personally speaking, I used Cython for quick & easy alternative way to
writing extension types.
I don't need compatibility with pure Python functions.  I prefer
minimum and lightweight.
So I will disable it explicitly or stop using Cython.

But if you believe PEP 580 makes many Cython users happy, I believe you.

-- 
INADA Naoki  <songofacandy at gmail.com>


More information about the Python-Dev mailing list