From: Petr Viktorin Date: Fri, 6 Jun 2025 14:51:40 +0000 (+0200) Subject: gh-57089: Note _layout_ in the bitfield docs (GH-134148) X-Git-Tag: v3.15.0a1~1368 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b22b964a5c245e13ae0439c5efbb8984acf607ab;p=thirdparty%2FPython%2Fcpython.git gh-57089: Note _layout_ in the bitfield docs (GH-134148) Co-authored-by: Meador Inge Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index 8e74c6c9dee7..2ee4450698a1 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 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 +behavior and how to change it. .. _ctypes-arrays: