Skip to content

Commit 5a0c79e

Browse files
committed
PEP 3118: Clarify format string "unimplemented" note
In order to wrap up the discussion around the choice of ``Zd`` vs. ``D`` a bit, I propose changing the "not implemented" note a bit. Not sure if it comes quite across, but I think: 1. There is no good reason to break with any of the "additions" here (I.e. don't use `&` to mean something different). 2. Python should feel free to diverge, but I think the note pointing to NumPy (which is "just" an example) hopefully makes it clear that this isn't a void.
1 parent 8785979 commit 5a0c79e

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

‎peps/pep-3118.rst‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Post-History: `09-Apr-2007 <https://mail.python.org/archives/list/python-dev@pyt
1414
Not all features proposed here were implemented. Specifically:
1515

1616
- ``PyObject_CopyToObject`` was not added.
17-
- :ref:`3118-struct-additions` were not added, except for ``?`` (``_Bool``).
17+
- :ref:`3118-struct-additions` were only partially adopted by Python
18+
and downstream libraries (see note there).
1819
- ``PyObject_GetMemoryView`` is named
1920
:external+python:c:type:`PyMemoryView_FromObject`.
2021

@@ -648,6 +649,15 @@ object that does not provide the protocol.
648649
Additions to the struct string-syntax
649650
=====================================
650651

652+
.. note::
653+
654+
Not all of the proposed extensions are implemented by Python, and
655+
downstream libraries like NumPy use only a subset (i.e., NumPy does not
656+
use ``X{}``, ``t``, ``&``, or the historic narrow-build ucs-2 ``u``).
657+
Future additions to the buffer protocol format string should aim
658+
not to conflict with the additions proposed here. However, Python
659+
may adopt different conventions for those it has not implemented.
660+
651661
The struct string-syntax is missing some characters to fully
652662
implement data-format descriptions already available elsewhere (in
653663
ctypes and NumPy for example). The Python 2.5 specification is
@@ -666,8 +676,8 @@ Character Description
666676
'u' ucs-2
667677
'w' ucs-4
668678
'O' pointer to Python Object
669-
'Z' complex (whatever the next specifier is)
670-
'&' specific pointer (prefix before another character)
679+
'Z<specifier>' complex (whatever the next specifier is, e.g. ``'Zd'``)
680+
'&<specifier>' specific pointer (e.g. ``'&i'`` for a pointer to an int)
671681
'T{}' structure (detailed layout inside {})
672682
'(k1,k2,...,kn)' multi-dimensional array of whatever follows
673683
':name:' optional name of the preceding element

0 commit comments

Comments
 (0)