[Python-3000] Metaclasses in Py3K

Talin talin at acm.org
Tue Dec 19 04:57:16 CET 2006


Greg Ewing wrote:
> Talin wrote:
> 
>> Do you have a specific proposal as to how the information about the 
>> ordering of definitions could be extracted? I'm assuming that there 
>> would be an extra attribute that would return a list of keys in the 
>> order that they were defined.
> 
> An extra attribute or method would be one obvious way.
> 
> Another way would be to have the existing items() and
> iteritems() methods return a list in the appropriate
> order.

That's a good idea.

>> One tricky part here is if the same key were to be defined twice (i.e. 
>> being overwritten the second time), we probably would only want it to 
>> appear once, probably at the location where it was defined last.
> 
> That sounds reasonable, but if anyone wanted to argue
> that both definitions should be preserved, I wouldn't
> object.

Now that I think about it, you are right - it's probably better to let 
the metaclass deal with the ambiguous case if it really wants to. And 
that makes the dict implementation trivial.

So it really sounds like all that is needed, then, is a suitable mapping 
class to use for class definition. It will have to be a built-in, 
however, since class creation depends on it.

I'm not going to say anymore on this topic then, now that the marching 
orders have been given out. I'll move it over to the appropriate list 
when it gets created. :)

-- Talin


More information about the Python-3000 mailing list