how to get bytes from bytearray without copying
Cameron Simpson
cs at zip.com.au
Sun Mar 2 20:47:58 EST 2014
On 02Mar2014 17:55, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On Sun, Mar 2, 2014 at 5:44 PM, Cameron Simpson <cs at zip.com.au> wrote:
> > Have you considered subclassing memoryview and giving the subclass
> > a __hash__ method?
>
> >>> class MyMemoryView(memoryview):
> ... def __hash__(self): return 42
> ...
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: type 'memoryview' is not an acceptable base type
Ah. The slices were going to be an issue too, anyway.
He could write a wrapper class with a __hash__ method, whose slices
themselves are also the wrapper class.
It raises the implementation bar only slightly.
Cheers,
--
Cameron Simpson <cs at zip.com.au>
Please do not send me Microsoft Word files.
http://en.nothingisreal.com/wiki/Please_don't_send_me_Microsoft_Word_documents
More information about the Python-list
mailing list