[Python-ideas] Re: C API for converting Python integers to/from bytes sequences

2021-08-11 Thread Ronald Oussoren via Python-ideas
> On 8 Aug 2021, at 18:53, Serhiy Storchaka wrote: > > 08.08.21 07:08, Stephen J. Turnbull пише: >> Serhiy Storchaka writes: >> >>> Python integers have arbitrary precision. For serialization and >>> interpolation with other programs and libraries we need to >>> represent them [...]. [In the

[Python-ideas] Re: C API for converting Python integers to/from bytes sequences

2021-08-08 Thread Christopher Barker
On Sun, Aug 8, 2021 at 9:54 AM Serhiy Storchaka wrote: > 1. Support conversion to/from all C integer types (char, short, int, > long, long long, intN_t, intptr_t, intmax_t, wchar_t, wint_t and > corresponding unsigned types), I suggest support for the "new" C sized types available in Why anyo

[Python-ideas] Re: C API for converting Python integers to/from bytes sequences

2021-08-08 Thread Kyle Stanley
I lack the relevant experience to have an opinion on most of this, but FWIW "PyLong_FromBytes/PyLong_ToBytes' seems clearest to me out of the options proposed. On Sat, Aug 7, 2021 at 2:23 PM Serhiy Storchaka wrote: > Python integers have arbitrary precision. For serialization and > interpolation

[Python-ideas] Re: C API for converting Python integers to/from bytes sequences

2021-08-08 Thread Serhiy Storchaka
08.08.21 11:41, Barry Scott пише: >> On 7 Aug 2021, at 19:22, Serhiy Storchaka 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

[Python-ideas] Re: C API for converting Python integers to/from bytes sequences

2021-08-08 Thread Serhiy Storchaka
08.08.21 07:08, Stephen J. Turnbull пише: > Serhiy Storchaka writes: > > > Python integers have arbitrary precision. For serialization and > > interpolation with other programs and libraries we need to > > represent them [...]. [In the case of non-standard precisions,] > > [t]here are private

[Python-ideas] Re: C API for converting Python integers to/from bytes sequences

2021-08-08 Thread 2QdxY4RzWzUUiLuE
On 2021-08-08 at 09:41:34 +0100, Barry Scott wrote: > What is mixed endian? I would guess that its use would be application > specific - so I assume you would not need to support it. Not AFAIK application specific, but hardware specific: https://en.wikipedia.org/wiki/Endianness#Mixed __

[Python-ideas] Re: C API for converting Python integers to/from bytes sequences

2021-08-08 Thread Barry Scott
> On 7 Aug 2021, at 19:22, Serhiy Storchaka wrote: > > Python integers have arbitrary precision. For serialization and > interpolation with other programs and libraries we need to represent > them as fixed-width integers (little- and big-endian, signed and > unsigned). In Python, we can use st