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

Stefan Krah stefan at bytereef.org
Thu Aug 18 22:25:59 CEST 2011


Antoine Pitrou <solipsis at pitrou.net> wrote:
> (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 :-))

I don't want to abolish the "c" (bytes of length 1) format. :)

I think there are use cases for well defined arrays of small signed/unsigned
integers. Say you want to send a log-ngram array of unsigned chars over the
network. There shouldn't be a bytes object involved in that process. You
would pack the array with ints and unpack as ints.

Unless the struct module and PEP-3118 grow support for int8_t and uint8_t,
I think "b" and "B" should probably be restricted to integers.


Stefan Krah





More information about the Python-Dev mailing list