This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients benjamin.peterson, rhettinger, terry.reedy
Date 2010-06-09.00:17:14
SpamBayes Score 0.028159607
Marked as misclassified No
Message-id <1276042637.75.0.116609326088.issue8945@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2010-06-09 00:17:17rhettingersetrecipients: + rhettinger, terry.reedy, benjamin.peterson
2010-06-09 00:17:17rhettingersetmessageid: <1276042637.75.0.116609326088.issue8945@psf.upfronthosting.co.za>
2010-06-09 00:17:15rhettingerlinkissue8945 messages
2010-06-09 00:17:14rhettingercreate