- Python 3.14 added
DandFformats to the ctypes andstructmodule - Python 3.15 adds
DandFformats to thearraymodule and tomemoryview
The D and F formats were chosen for compatibility with numpy. Problem: in fact, numpy uses buffer formats Zd and Zf. Example:
>>> import numpy as np >>> memoryview(np.array([1, 2, 3], dtype='F')).format 'Zf' >>> memoryview(np.array([1, 2, 3], dtype='D')).format 'Zd'
So I propose adding support for Zd and Zf formats in array, ctypes, memoryview and struct. It requires changing the code expecting a single character to now accept a string (Zd and Zf have 2 characters!).
Linked PRs
- gh-148675: Add Zd/Zf formats to array, ctypes, memoryview, struct #148676
- gh-148675: Revert GH-146237 and GH-146241 #148674
- gh-148675: Remove F and D formats from array and memoryview #149368
- gh-148675: Optimize arraydescr structure: use char[3] #149455
- gh-148675: Use a string for ctypes cparam tag #149778
- gh-148675: Reuse typecodes for array.array() error message #149779
- [3.15] gh-148675: Use a string for ctypes cparam tag (GH-149778) #149869