]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-46906: Add PyFloat_Pack8() to the C API (GH-31657)
authorVictor Stinner <vstinner@python.org>
Fri, 11 Mar 2022 23:10:02 +0000 (00:10 +0100)
committerGitHub <noreply@github.com>
Fri, 11 Mar 2022 23:10:02 +0000 (00:10 +0100)
commit882d8096c262a5945e0cfdd706e5db3ad2b73543
tree5e903c7e87a13203543e3e215f30b6b708df018d
parentecfff63e06e77e22035a7f7caa26986f033f3aea
bpo-46906: Add PyFloat_Pack8() to the C API (GH-31657)

Add new functions to pack and unpack C double (serialize and
deserialize):

* PyFloat_Pack2(), PyFloat_Pack4(), PyFloat_Pack8()
* PyFloat_Unpack2(), PyFloat_Unpack4(), PyFloat_Unpack8()

Document these functions and add unit tests.

Rename private functions and move them from the internal C API
to the public C API:

* _PyFloat_Pack2() => PyFloat_Pack2()
* _PyFloat_Pack4() => PyFloat_Pack4()
* _PyFloat_Pack8() => PyFloat_Pack8()
* _PyFloat_Unpack2() => PyFloat_Unpack2()
* _PyFloat_Unpack4() => PyFloat_Unpack4()
* _PyFloat_Unpack8() => PyFloat_Unpack8()

Replace the "unsigned char*" type with "char*" which is more common
and easy to use.
13 files changed:
Doc/c-api/float.rst
Doc/whatsnew/3.11.rst
Include/cpython/floatobject.h
Include/internal/pycore_floatobject.h
Lib/test/test_float.py
Misc/NEWS.d/next/C API/2022-03-03-11-12-33.bpo-46906.-olyBI.rst [new file with mode: 0644]
Modules/_ctypes/cfield.c
Modules/_pickle.c
Modules/_struct.c
Modules/_testcapimodule.c
Modules/arraymodule.c
Objects/floatobject.c
Python/marshal.c