Repository navigation
Add support for numpy buffer format Zf and Zd #148675
Description
Activity
- addedinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
on Apr 17, 2026 This issue was escalated to the Steering Council: Decide buffer protocol format string for complex numbers.
The D and F formats were chosen for #132827. Problem: in fact, numpy uses buffer formats Zd and Zf.
In fact, numpy uses both. So, 'F'/'D' codes does make sense for the ctypes module, at least. If SC approves the compatibility break - we can change buffer formats to Zd/Zf in the ctypes module.
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!).
I think it's better to revert changes for array and memoryview (#148674) and leave problem for a new champion, who will make a PEP with a proper extension of the struct format string for new types.
Reacted by Petr Viktorin- addedtype-featureA feature request or enhancementA feature request or enhancement
on Apr 17, 2026 Are we all done here for 3.15?
For b1, yes. The Steering Council will need to discuss this, later.
Reacted by Hugo van Kemenade9 remaining items
- added 4 commits that reference this issue
on May 7, 2026 - added 4 commits that reference this issue
on May 13, 2026 Add support for numpy buffer format Zf and Zd
The initial issue has been implemented. For further work, please open new issue. I close this one.
- moved this from Todo to Done in Release and Deferred blockers 🚫
on May 18, 2026
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
DandFformats to the ctypes andstructmoduleDandFformats to thearraymodule and tomemoryviewThe
DandFformats were chosen for compatibility with numpy. Problem: in fact, numpy uses buffer formatsZdandZf. Example:So I propose adding support for
ZdandZfformats inarray,ctypes,memoryviewandstruct. It requires changing the code expecting a single character to now accept a string (ZdandZfhave 2 characters!).Linked PRs