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


Groups > comp.lang.python > #67519

Re: how to get bytes from bytearray without copying

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.018
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'from:charset:iso-8859-2': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'api': 0.11; 'python': 0.11; 'bullet': 0.16; 'read-only.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'solution.': 0.20; 'header:User- Agent:1': 0.23; 'bytes': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'probably': 0.32; 'url:python': 0.33; 'subject:from': 0.34; 'could': 0.34; 'object,': 0.36; 'thanks': 0.36; "i'll": 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'ian': 0.60; 'worry': 0.60; 'url:3': 0.61; 'charset:iso-8859-2': 0.64; 'received:93': 0.72; 'subject:get': 0.81; 'bite': 0.84; 'received:hr': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Juraj Ivančić <juraj.ivancic@gmail.com>
Subject Re: how to get bytes from bytearray without copying
Date Mon, 03 Mar 2014 10:09:56 +0100
References <lf0h3g$m7r$1@ger.gmane.org> <CALwzidncPvJS_aPJENre2HfOvV_PoY8mSV4PGA+i8FcwYPFc=A@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-2; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 93-136-72-166.adsl.net.t-com.hr
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0
In-Reply-To <CALwzidncPvJS_aPJENre2HfOvV_PoY8mSV4PGA+i8FcwYPFc=A@mail.gmail.com>
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.7630.1393837816.18130.python-list@python.org> (permalink)
Lines 16
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1393837816 news.xs4all.nl 2882 [2001:888:2000:d::a6]:39142
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:67519

Show key headers only | View raw


On 3.3.2014. 2:27, Ian Kelly wrote:

> Python 3.3 has a C API function to create a memoryview for a char*,
> that can be made read-only.
>
>      http://docs.python.org/3/c-api/memoryview.html#PyMemoryView_FromMemory

Yes, this is probably what I'll do in absence of pure Python solution. 
Thanks for the tip.

> Or you could bite the bullet and copy everything
> once at the start to create a bytes object, and then never have to
> worry about it again.

That would be a surrender :-)

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


Thread

Re: how to get bytes from bytearray without copying Juraj Ivančić <juraj.ivancic@gmail.com> - 2014-03-03 10:09 +0100

csiph-web