[Python-Dev] PEP 520: Ordered Class Definition Namespace

Eric Snow ericsnowcurrently at gmail.com
Mon Jun 20 21:30:20 EDT 2016


On Fri, Jun 17, 2016 at 7:32 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> The discussion in the PEP 487 thread made me realise that I'd like to
> see a discussion in PEP 520 regarding whether or not to define
> __definition_order__ for builtin types initialised via PyType_Ready or
> created via PyType_FromSpec in addition to defining it for types
> created via the class statement or types.new_class().
>
> For static types, PyType_Ready could potentially set it based on
> tp_members, tp_methods & tp_getset (see
> https://docs.python.org/3/c-api/typeobj.html )
> Similarly, PyType_FromSpec could potentially set it based on the
> contents of Py_tp_members, Py_tp_methods and Py_tp_getset slot
> definitions
>
> Having definition order support in both types.new_class() and builtin
> types would also make it clear why we can't rely purely on the
> compiler to provide the necessary ordering information - in both of
> those cases, the Python compiler isn't directly involved in the type
> creation process.

I'll mention this in the PEP, but I'd rather not make it a part of the proposal.

-eric


More information about the Python-Dev mailing list