08.08.21 11:41, Barry Scott пише:
>> On 7 Aug 2021, at 19:22, Serhiy Storchaka <storch...@gmail.com> wrote:
>> 1. How to encode the byte order?
>>
>> a) 1 -- little endian, 0 -- big endian
>> b) 0 -- little endian, 1 -- big endian
>> c) -1 -- little endian, +1 -- big endian, 0 -- native endian.
> 
> Use an enum and do not use 0 as a valid value to make mistakes easier to 
> detect.
> I think you are right to have big endian, little endian and native endian.
> I do not think the numeric values of the enum matter (apart from avoiding 0).

There is a precedence of using +1/-1/0 for big/little/native in the
UTF16 and UTF32 codecs. I think that using the same convention will be
more error-proof.

> Maybe a single enum that has:
> signed (modulo)
> signed saturate
> unsigned (modulo)
> unsigned saturate

There is a problem with enum -- the size of the type is not specified.
It can be int, it can be 8 bits, it can be less than 8 bits in
structure. Adding new members can change the size of the type. Therefore
it is not stable for ABI.

But combining options for signessness and overflow handling (or
providing a set of functions for different overflow handling, because
the output overflow parameters is not in all cases) may be the best option.

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/QETPJWGWERSQYY2VE25HDJBIFUEZUF25/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to