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

From Juraj Ivančić <juraj.ivancic@gmail.com>
Subject Re: how to get bytes from bytearray without copying
Date 2014-03-03 10:09 +0100
References <lf0h3g$m7r$1@ger.gmane.org> <CALwzidncPvJS_aPJENre2HfOvV_PoY8mSV4PGA+i8FcwYPFc=A@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.7630.1393837816.18130.python-list@python.org> (permalink)

Show all headers | 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