summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorSergey B Kirpichev <skirpichev@gmail.com>2024-10-07 11:53:02 (GMT)
committerGitHub <noreply@github.com>2024-10-07 11:53:02 (GMT)
commit7487db4c7af629f0a81b2127a3ee0000a288cefc (patch)
tree1cc74f0158815fcbb263df22eaac3720ac43a64a /Doc
parentf55273b3b7124dc570911724107c2440f37905fc (diff)
downloadcpython-7487db4c7af629f0a81b2127a3ee0000a288cefc.zip
cpython-7487db4c7af629f0a81b2127a3ee0000a288cefc.tar.gz
cpython-7487db4c7af629f0a81b2127a3ee0000a288cefc.tar.bz2
gh-121249: Support _Complex types in the struct module (#121613)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/struct.rst19
1 files changed, 19 insertions, 0 deletions
diff --git a/Doc/library/struct.rst b/Doc/library/struct.rst
index 4769aff..3ea9e5b 100644
--- a/Doc/library/struct.rst
+++ b/Doc/library/struct.rst
@@ -267,12 +267,26 @@ platform-dependent.
| ``P`` | :c:expr:`void \*` | integer | | \(5) |
+--------+--------------------------+--------------------+----------------+------------+
+Additionally, if IEC 60559 compatible complex arithmetic (Annex G of the
+C11 standard) is supported, the following format characters are available:
+
++--------+--------------------------+--------------------+----------------+------------+
+| Format | C Type | Python type | Standard size | Notes |
++========+==========================+====================+================+============+
+| ``E`` | :c:expr:`float complex` | complex | 8 | \(10) |
++--------+--------------------------+--------------------+----------------+------------+
+| ``C`` | :c:expr:`double complex` | complex | 16 | \(10) |
++--------+--------------------------+--------------------+----------------+------------+
+
.. versionchanged:: 3.3
Added support for the ``'n'`` and ``'N'`` formats.
.. versionchanged:: 3.6
Added support for the ``'e'`` format.
+.. versionchanged:: 3.14
+ Added support for the ``'E'`` and ``'C'`` formats.
+
Notes:
@@ -349,6 +363,11 @@ Notes:
of bytes. As a special case, ``'0s'`` means a single, empty string (while
``'0c'`` means 0 characters).
+(10)
+ For the ``'E'`` and ``'C'`` format characters, the packed representation uses
+ the IEEE 754 binary32 and binary64 format for components of the complex
+ number, regardless of the floating-point format used by the platform.
+
A format character may be preceded by an integral repeat count. For example,
the format string ``'4h'`` means exactly the same as ``'hhhh'``.