[Python-Dev] Sign of bytes (original) (raw)

Xavier Morel python-dev at masklinn.net
Wed Oct 31 19:19:07 CET 2012


On 2012-10-31, at 18:44 , anatoly techtonik wrote:

I wonder why Python uses signed chars for bytes http://docs.python.org/2/library/ctypes.html#ctypes.cbyte

That's not Python, that's ctypes. struct[0] has no "bytes" it uses "char" for everything.

If I had to guess, it would be because "char" is already an unsigned char in ctypes, "signed_char" is way too long, "schar" looks like dog vomit and there was no point in aliasing "byte" to "char. Which left "byte" free for "signed char".

[0] http://docs.python.org/2/library/struct.html#format-characters



More information about the Python-Dev mailing list