osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] PEP 575: Unifying function/method classes


On 13 April 2018 at 02:12, Jeroen Demeyer <J.Demeyer at ugent.be> wrote:
> Dear Python developers,
>
> I would like to request a review of PEP 575, which is about changing the
> classes used for built-in functions and Python functions and methods. The
> text of the PEP can be found at
>
> https://www.python.org/dev/peps/pep-0575/
>
> No substantial changes to the contents of the PEP were made compared to the
> first posting. However, many details have been changed, clarified or added,
> based on comments from the initial discussion thread and the work on an
> implementation.

I'm personally +1 on this version of the PEP (thank you for putting it
together!), but have one request for clarification related to
`__doc__`: at first glance, it isn't obvious why there are two
different ways of storing the docstring (either m_ml->ml_doc or a
dedicated func_code field).

Those technically *could* be consolidated by always using
m_ml->ml_doc, and changing the definition of base_function such that
m_ml always pointed to a PyMethodDef instance.

However, that's less than ideal when the doc string is already a
Python object, since you need to convert between "const char *" and
"PyObject *" when accessing the field from Python (and vice versa when
setting it).

There's also a section in the rationale which refers to METH_USRx
flags, which I'm guessing from context are an idea you were
considering proposing, but eventually dropped from the rest of the
PEP. These remaining references to the concept just need to be cleaned
up.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia