Erik wrote:
That's one of the points I'm trying to make - why is it harder than it needs to be to do something this simple?
The built-in dict class is used internally to implement various namespaces (module, class, instance, etc.), so it needs to be extremely efficient. Funnelling all updates through a single method would be unacceptable. This does make it harder to override behaviour in a subclass, but that's always a tricky proposition that relies on knowing a lot about implementation details of the class. If a particular method isn't documented as being a hook intended for overriding, you can't make any assumptions.
The other is that the documentation of collections.OrderedDict seems to be lacking (it is talking in terms of being a "dict" subclass, but it actually isn't one).
The docs probably mean to say that it has the same interface as a dict, not that it's necessarily implemented as a subclass of dict. Nevertheless, it could actually be a dict subclass that overrides all the necessary methods. Either way, its behaviour under subclassing is not spelled out. -- Greg -- https://mail.python.org/mailman/listinfo/python-list