A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2011-August/112920.html below:

[Python-Dev] memoryview: "B", "c", "b" format specifiers

[Python-Dev] memoryview: "B", "c", "b" format specifiersAntoine Pitrou solipsis at pitrou.net
Thu Aug 18 18:40:40 CEST 2011
On Thu, 18 Aug 2011 18:22:54 +0200
Stefan Krah <stefan at bytereef.org> wrote:
> 
> So, memoryview does exactly the opposite of what is specified. It should
> reject the bytes object but accept the integer.

Well, memoryview is quite dumb right now. It ignores the format and
just considers its underlying memory a bytes sequence.

> I would like to fix this in the features/pep-3118 repository as follows:
> 
>   - memoryview should respect the format specifiers.
> 
>   - bytearray and friends should set the format specifier to "c"
>     in their getbuffer() methods.
> 
>   - Introduce a new function PyMemoryView_FromBytes() that can be used
>     instead of PyMemoryView_FromBuffer(). PyMemoryView_FromBuffer()
>     is usually used in conjunction with PyBuffer_FillInfo(), which
>     sets the format specifier to "B".

What would PyMemoryView_FromBytes() do? The name suggests it takes a
bytes object, but you can already use PyMemoryView_FromObject() for
that.

(I personnaly think the general bytes-as-sequence-of-ints behaviour is
a mistake, so I wouldn't care much about an additional C API to enforce
that behaviour :-))

Regards

Antoine.


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4