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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'anyway.': 0.05; 'method,': 0.09; 'raises': 0.09; 'slices': 0.09; 'wrapper': 0.09; 'def': 0.12; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'subclass': 0.16; 'subclassing': 0.16; 'typeerror:': 0.16; 'files.': 0.16; 'wrote:': 0.18; "skip:' 30": 0.19; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'cheers,': 0.24; 'class.': 0.26; 'header:In-Reply-To:1': 0.27; 'url:wiki': 0.31; '"",': 0.31; 'file': 0.32; 'class': 0.32; 'themselves': 0.32; '(most': 0.33; 'skip:_ 10': 0.34; 'subject:from': 0.34; 'could': 0.34; 'acceptable': 0.36; 'received:com.au': 0.36; 'charset:us- ascii': 0.36; 'received:211': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'pm,': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'ian': 0.60; 'content-disposition:inline': 0.62; 'mar': 0.68; 'subject:get': 0.81
Date Mon, 3 Mar 2014 12:47:58 +1100
From Cameron Simpson <cs@zip.com.au>
To Python <python-list@python.org>
Subject Re: how to get bytes from bytearray without copying
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
In-Reply-To <CALwzidmKL25AR3MLf3EKNtk+C_BnopcZCmDDzDYK9j4ODDGifg@mail.gmail.com>
User-Agent Mutt/1.5.21 (2010-09-15)
References <CALwzidmKL25AR3MLf3EKNtk+C_BnopcZCmDDzDYK9j4ODDGifg@mail.gmail.com>
X-Optus-CM-Score 0
X-Optus-CM-Analysis v=2.1 cv=Wu4Sb7vv c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=GCYxRCg_PokA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=pGLkceISAAAA:8 a=8VBKUW4WAAAA:8 a=OQtmAiQXlCzRQAk_v58A:9 a=CjuIK1q_8ugA:10 a=MSl-tDqOz04A:10
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.7616.1393811289.18130.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1393811289 news.xs4all.nl 2848 [2001:888:2000:d::a6]:39048
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:67497

Show key headers only | 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