mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-121249: unconditionally support complex
types in struct
(GH-132864)
Co-authored-by: Lisandro Dalcin <dalcinl@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
parent
e6c518d2eb
commit
f425509349
5 changed files with 21 additions and 89 deletions
|
@ -260,6 +260,10 @@ platform-dependent.
|
|||
+--------+--------------------------+--------------------+----------------+------------+
|
||||
| ``d`` | :c:expr:`double` | float | 8 | \(4) |
|
||||
+--------+--------------------------+--------------------+----------------+------------+
|
||||
| ``F`` | :c:expr:`float complex` | complex | 8 | \(10) |
|
||||
+--------+--------------------------+--------------------+----------------+------------+
|
||||
| ``D`` | :c:expr:`double complex` | complex | 16 | \(10) |
|
||||
+--------+--------------------------+--------------------+----------------+------------+
|
||||
| ``s`` | :c:expr:`char[]` | bytes | | \(9) |
|
||||
+--------+--------------------------+--------------------+----------------+------------+
|
||||
| ``p`` | :c:expr:`char[]` | bytes | | \(8) |
|
||||
|
@ -267,17 +271,6 @@ 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 |
|
||||
+========+==========================+====================+================+============+
|
||||
| ``F`` | :c:expr:`float complex` | complex | 8 | \(10) |
|
||||
+--------+--------------------------+--------------------+----------------+------------+
|
||||
| ``D`` | :c:expr:`double complex` | complex | 16 | \(10) |
|
||||
+--------+--------------------------+--------------------+----------------+------------+
|
||||
|
||||
.. versionchanged:: 3.3
|
||||
Added support for the ``'n'`` and ``'N'`` formats.
|
||||
|
||||
|
@ -367,6 +360,11 @@ Notes:
|
|||
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.
|
||||
Note that complex types (``F`` and ``D``) are available unconditionally,
|
||||
despite complex types being an optional feature in C.
|
||||
As specified in the C11 standard, each complex type is represented by a
|
||||
two-element C array containing, respectively, the real and imaginary parts.
|
||||
|
||||
|
||||
A format character may be preceded by an integral repeat count. For example,
|
||||
the format string ``'4h'`` means exactly the same as ``'hhhh'``.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue