It was reported to NumPy that the newly added buffer protocol support for complex array.array and ctypes uses the character codes D and F rather than Zd and Zf.
Now, it’s a fair choice to accept the friction that this introduces, but for now it is still unclear that this was considered much and I think it is a violation of the PEP.
Yeah, I understand that the PEP said parts of it weren’t implemented and it’s a historical documented, although I would read it as “by Python itself” not as a rejection of the syntax.
So the question is simple, using D vs. Zd is a bit neater to implement, as it means things follow the struct module exactly and I can understand that the choice there went to D.
But, it means one of the following:
- NumPy (and that means all meaningful users of the buffer protocol) would have to keep exporting
Zd(and Python doesn’t understand this!). NumPy and everyone else would have to exportEDIT: Sorry, not a real option since stable ABI extensions exist and that would break them all.Don Python 3.15+ andZdon older versions meaning an API break for downstream.
Or I guess the other question is: Does it make sense from the Python to avoid a bit of friction in it’s complex buffer protocol implementation (to me it seems like a bit, but I dunno) or is the slow above transition worthwhile?
(Historically, I have no idea what the background is. Since NumPy used D already, I wouldn’t be suprised if, at the time of the PEP, Zd was a preference by Python. But it could also have been one the scientific python side because they e.g. felt that Zi could make sense and single letters are really limiting…)