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 xiang.zhang
Recipients benjamin.peterson, daniel.urban, eltoder, eric.araujo, eric.snow, gvanrossum, jwilk, maciej.szulik, mark.dickinson, nadeem.vawda, pitrou, rhettinger, terry.reedy, thet, xiang.zhang
Date 2016-05-30.16:21:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1464625306.13.0.546748437124.issue5996@psf.upfronthosting.co.za>
In-reply-to
Content
I think subclassing builtin types and making it abstract is rare. And when there is a need, we can mimic this in application level (this may also apply to types having custom __new__):

In [2]: class CustomDict(dict, metaclass=abc.ABCMeta):
   ...:     def __new__(cls, *args, **kwargs):
   ...:         if getattr(cls, '__abstractmethods__', None):
   ...:             raise TypeError
   ...:         return super().__new__(cls, *args, **kwargs)
   ...:     @abc.abstractmethod
   ...:     def f(self):
   ...:         pass

Adding the abstract class checking in tp_alloc or builtin types' tp_new maybe degrade performance.

Is it necessary to add this support?
History
Date User Action Args
2016-05-30 16:21:46xiang.zhangsetrecipients: + xiang.zhang, gvanrossum, rhettinger, terry.reedy, mark.dickinson, pitrou, nadeem.vawda, benjamin.peterson, jwilk, eric.araujo, thet, daniel.urban, eltoder, eric.snow, maciej.szulik
2016-05-30 16:21:46xiang.zhangsetmessageid: <1464625306.13.0.546748437124.issue5996@psf.upfronthosting.co.za>
2016-05-30 16:21:46xiang.zhanglinkissue5996 messages
2016-05-30 16:21:45xiang.zhangcreate