Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #67497

Re: how to get bytes from bytearray without copying

Date 2014-03-03 12:47 +1100
From Cameron Simpson <cs@zip.com.au>
Subject Re: how to get bytes from bytearray without copying
References <CALwzidmKL25AR3MLf3EKNtk+C_BnopcZCmDDzDYK9j4ODDGifg@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.7616.1393811289.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 02Mar2014 17:55, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Sun, Mar 2, 2014 at 5:44 PM, Cameron Simpson <cs@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@zip.com.au>

Please do not send me Microsoft Word files.
http://en.nothingisreal.com/wiki/Please_don't_send_me_Microsoft_Word_documents

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: how to get bytes from bytearray without copying Cameron Simpson <cs@zip.com.au> - 2014-03-03 12:47 +1100

csiph-web