[Python-ideas] PEP proposal: unifying function/method classes

Nick Coghlan ncoghlan at gmail.com
Sat Mar 24 23:52:17 EDT 2018


On 25 March 2018 at 07:38, Jeroen Demeyer <J.Demeyer at ugent.be> wrote:

> Dear Nick Coghlan,
>
> First of all, thanks for your insightful comments!
>
> On 2018-03-24 09:09, Nick Coghlan wrote:
>
>> As Antoine notes, unifying user-defined functions and builtin functions
>> would be fraught with backwards compatibility problems, so you probably
>> don't want to go down that path when your goal is "Let third parties
>> define types that are recognised by the core interpreter as being
>> user-defined functions".
>>
>
> First of all, my post was mainly meant to get an answer to "is this idea
> PEP-able?". I have never written a PEP and PEP 1 recommends this step. So
> it's not clear whether you want to say "that potential PEP is a bad idea"
> or just "go ahead with your PEP but be aware of backwards compatibility
> issues".
>
> It would be good to know what your backwards compatibility worries are. If
> I have a clearer idea of what could break, it would be easier to see if
> it's possible to not break that.
>

The biggest problem would have been the potential change to the descriptor
behaviour - making CPython's C functions behave like instance methods
instead of static methods would create a significant compatibility risk for
no clear benefit.

However, from the rest of your email, it sounds like you're not actually
proposing to change that and I'd just misunderstood what you were
suggesting, so I now think it's a promising idea that should help not only
Cython, but also other binding generation projects like cffi, SWIG, Boost,
etc :)

Cheers,
Nick.

P.S. You're also right that I'd missed the fact that the fast paths that
you want to follow at runtime are the PyCFunction ones, so you really do
need to be able to define a hybrid type that executes like a builtin C
function, but supports introspection like a native Python function.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180325/9a853e05/attachment-0001.html>


More information about the Python-ideas mailing list