Raymond Hettinger <rhettin...@users.sourceforge.net> added the comment:
Somewhere, we should document the-facts-of-life for subclassing builtins. 1) For the most part, C code has the pattern if isinstance(obj, some_builtin_type): call the built_type's methods directly using slotted methods otherwise: use slower getattribute style calls 2) A subclasser of a dict needs to actually populate the dict with the values they want used. The built-in dict class is "open for extension and closed for modification" -- the open/closed principle. This is necessary or else a subclasser could easily break the built-in type's invariants and crash python. 3) For the most part, only something like subclassing UserDict gives you full control. ---------- nosy: +rhettinger _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue8945> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com