From 78d7745b4f8ac6d072d6916d8164f0dc712caea7 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Sat, 17 May 2025 19:07:15 +0200 Subject: [PATCH 1/2] gh-57089: Note _layout_ in the bitfield docs Co-Authored-By: Meador Inge --- Doc/library/ctypes.rst | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index 5b733d5321e907..889c6b76aafc8f 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -714,10 +714,16 @@ item in the :attr:`~Structure._fields_` tuples:: ... ("second_16", c_int, 16)] ... >>> print(Int.first_16) - + >>> print(Int.second_16) - - >>> + + +It is important to note that bit field allocation and layout in memory is not +defined as a C standard; its implementation is compiler-specific. +By default, Python will attempt to match the behavior of a "native" compiler +for the current platform. +See the :attr:`~Structure._layout_` attribute for details on the default +behavior and how to change it. .. _ctypes-arrays: From ad9405354c89f62c562a471f354934f382cb9597 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Fri, 6 Jun 2025 16:29:03 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Doc/library/ctypes.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index 889c6b76aafc8f..36fe239156d709 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -718,8 +718,8 @@ item in the :attr:`~Structure._fields_` tuples:: >>> print(Int.second_16) -It is important to note that bit field allocation and layout in memory is not -defined as a C standard; its implementation is compiler-specific. +It is important to note that bit field allocation and layout in memory are not +defined as a C standard; their implementation is compiler-specific. By default, Python will attempt to match the behavior of a "native" compiler for the current platform. See the :attr:`~Structure._layout_` attribute for details on the default