Author ncoghlan
Recipients Arfrever, daniel.urban, ezio.melotti, flox, jcea, ncoghlan
Date 2013-03-14.07:24:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1363245872.8.0.491295317527.issue17044@psf.upfronthosting.co.za>
In-reply-to
Content
I hadn't noticed that type.__new__ copied the contents (it surprises me that it does both that *and* restricts the input type to a true dict instance).

The "Extending a class" example should still work as shown, since the magic of that happens while the body of ExtendedExample is running.

For the order preserving case, it turns out CPython already keeps a copy of the original namespace around as cls.__locals__, but this is currently undocumented (as far as I can tell anyway).

If we elevate that to documented behaviour, then __init_class__ implementations can reference both the original object, as well as the snapshot underlying the class object.

Given that, it is probably also better to revert the namespace keyword to accepting an instance rather than a factory function, since the copy operation after execution of the class body is automatic.
History
Date User Action Args
2013-03-14 07:24:32ncoghlansetrecipients: + ncoghlan, jcea, ezio.melotti, Arfrever, flox, daniel.urban
2013-03-14 07:24:32ncoghlansetmessageid: <1363245872.8.0.491295317527.issue17044@psf.upfronthosting.co.za>
2013-03-14 07:24:32ncoghlanlinkissue17044 messages
2013-03-14 07:24:32ncoghlancreate