Currently, we have support for this in the struct and the ctypes modules, working rather with heterogeneous binary data. Lets add these types to the array module as well ('F'/'D' type codes).
I think this feature can be available unconditionally, like for the struct module.
changed the title [-]Support complex (float/double) types in the array module[/-][+]Support complex (float/double) types in array.array and memoryview[/+]on Mar 19, 2026
BTW, currently the lack of support for 'F'/'D' types in the memoryview looks as a documentation error, it references the struct module formatting types.
Activity
serhiy-storchaka commented on Mar 19, 2026
If this is supported in the struct module, there is no reasons to not support it in array.array and memoryview.
pythongh-146151: support for complex arrays in the array module
pythongh-146151: memoryview supports 'F' and 'D' format types (complex)
skirpichev commented on Mar 21, 2026
BTW, currently the lack of support for 'F'/'D' types in the memoryview looks as a documentation error, it references the struct module formatting types.
gh-146151: memoryview supports 'F' and 'D' format types (complex) (#1…
gh-146151: Add support for complex arrays in the array module (#146237)
vstinner commented on Mar 26, 2026
I merged the two PRs (array and memoryview). I close the issue.
pythongh-146151: memoryview supports 'F' and 'D' format types (comple…
pythongh-146151: Add support for complex arrays in the array module (p…
Revert "pythongh-146151: Add support for complex arrays in the array …
Revert "pythongh-146151: memoryview supports 'F' and 'D' format types…
pythongh-146151: memoryview supports 'F' and 'D' format types (comple…
pythongh-146151: Add support for complex arrays in the array module (p…