[Python-ideas] An even simpler customization of class creation

Nick Coghlan ncoghlan at gmail.com
Sun Mar 1 07:48:10 CET 2015


On 1 March 2015 at 11:30, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> On Sat, Feb 28, 2015 at 10:10 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> That leaves my one concern being the "namespace" keyword parameter.
>> I'd started reconsidering that for PEP 422, and I think the argument
>> holds at least as strongly for your improved design:
>> https://www.python.org/dev/peps/pep-0422/#is-the-namespace-concept-worth-the-extra-complexity
>>
>> Since speed usually isn't a critical concern for class definitions,
>> it's likely better to just make them ordered by default, which can be
>> its own PEP, rather than being part of this one.
>
> FWIW, Guido already told me a while back that OrderedDict by default
> for class definition namespace was okay.  It's just been waiting on me
> to get back to the C OrderedDict implementation (which I've started to
> recently).

Yeah, that was the conversation that prompted me to question the
utility of the namespace keyword idea. The prototype class and class
extension examples are cute, but fall into the "don't do this in
production" category for me, making them prime candidates for custom
metaclasses.

The one really useful one is using an ordered dictionary for namespace
execution, and your solution addresses that better by just making it
the normal behaviour.

Cheers,
Nick.

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


More information about the Python-ideas mailing list