Message107370
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. |
|
Date |
User |
Action |
Args |
2010-06-09 00:17:17 | rhettinger | set | recipients:
+ rhettinger, terry.reedy, benjamin.peterson |
2010-06-09 00:17:17 | rhettinger | set | messageid: <1276042637.75.0.116609326088.issue8945@psf.upfronthosting.co.za> |
2010-06-09 00:17:15 | rhettinger | link | issue8945 messages |
2010-06-09 00:17:14 | rhettinger | create | |
|