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

2021-08-07 Thread 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 C API functions _PyLong_AsByteArray and >

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

2021-08-07 Thread Serhiy Storchaka
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 struct, array, memoryview and ctypes use for some standard sizes