Message373554
| Author |
mdehoon |
| Recipients |
mdehoon |
| Date |
2020年07月12日.14:23:23 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1594563804.44.0.878376005542.issue41285@roundup.psfhosted.org> |
| In-reply-to |
| Content |
Currently memoryview does not support subclassing:
>>> class B(memoryview): pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: type 'memoryview' is not an acceptable base type
Subclassing memoryview can be useful when
- class A supports the buffer protocol;
- class B wraps class A and should support the buffer protocol provided by class A;
- class A does not support subclassing.
In this situation,
class B(memoryview):
def __new__(cls, a):
return super(B, cls).__new__(cls, a)
where a is an instance of class A, would let instances of B support the buffer protocol provided by a.
Is there any particular reason why memoryview does not support subclassing? |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2020年07月12日 14:23:24 | mdehoon | set | recipients:
+ mdehoon |
| 2020年07月12日 14:23:24 | mdehoon | set | messageid: <1594563804.44.0.878376005542.issue41285@roundup.psfhosted.org> |
| 2020年07月12日 14:23:24 | mdehoon | link | issue41285 messages |
| 2020年07月12日 14:23:23 | mdehoon | create |
|