Message266704
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? |
|
Date |
User |
Action |
Args |
2016-05-30 16:21:46 | xiang.zhang | set | recipients:
+ 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:46 | xiang.zhang | set | messageid: <1464625306.13.0.546748437124.issue5996@psf.upfronthosting.co.za> |
2016-05-30 16:21:46 | xiang.zhang | link | issue5996 messages |
2016-05-30 16:21:45 | xiang.zhang | create | |
|