diff --git a/Doc/library/struct.rst b/Doc/library/struct.rst index 17fc479fd0c8c9..491b3b22c6b4cf 100644 --- a/Doc/library/struct.rst +++ b/Doc/library/struct.rst @@ -280,6 +280,10 @@ platform-dependent. .. versionchanged:: 3.14 Added support for the ``'F'`` and ``'D'`` formats. +Complex numbers may also be represented using two consecutive floating-point +format characters. In this case, the real part is stored first, followed by +the imaginary part. The format characters ``f`` and ``d`` determine the type +used for each component. Notes: diff --git a/Modules/_struct.c b/Modules/_struct.c index a8e9021f0a303a..bcd4f14bd10789 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -2696,7 +2696,9 @@ these can be preceded by a decimal repeat count:\n\ x: pad byte (no data); c:char; b:signed byte; B:unsigned byte;\n\ ?: _Bool (requires C99; if not available, char is used instead)\n\ h:short; H:unsigned short; i:int; I:unsigned int;\n\ - l:long; L:unsigned long; f:float; d:double; e:half-float.\n\ + l:long; L:unsigned long; f:float; d:double; e:half-float.\n\ + For complex numbers, the real and imaginary parts are represented by two\n\ + consecutive values of the specified floating-point type.\n\ Special cases (preceding decimal count indicates length):\n\ s:string (array of char); p: pascal string (with count byte).\n\ Special cases (only available in native format):\n\ diff --git a/test_PAT.txt b/test_PAT.txt new file mode 100644 index 00000000000000..e69de29bb2d1d6