Choice of complex buffer protocol format intentional break with PEP?

I’d like to see @ngoldbaum’s upcoming PEP before voting here. Of course, that won’t happen for 3.15 :‍)

My current recommendation would be:

In 3.16, default to Zd/Zf everywhere (struct, array, ctypes, memoryview). This needs a PEP, and the plan can change.

Whenever we parse the format (struct, memoryview), accept both F/D/G and Zd/Zf – regardless of which of them end up being canonical. This would be nice for 3.15 but can go in 3.16. (In some cases, adding support for 2-letter codes might be significant surgery.)

In array and memoryview.cast, support both F/D and Zd/Zf – re-export what the user specified. If that can’t be done in time for 3.15, revert the 3.15 changes.

In ctypes: In 3.14 and 3.15, document that complex numbers’ _type_, and exported buffer format, may change. Change them in 3.16, with SC approval for skipping the deprecation period.

4 Likes