https://github.com/python/cpython/commit/f32c7b9100e210a20000c431f8139437f403c88f commit: f32c7b9100e210a20000c431f8139437f403c88f branch: 3.14 author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com> committer: encukou <encu...@gmail.com> date: 2025-06-06T14:58:48Z summary:
[3.14] gh-57089: Note _layout_ in the bitfield docs (GH-134148) (GH-135216) (cherry picked from commit b22b964a5c245e13ae0439c5efbb8984acf607ab) Co-authored-by: Petr Viktorin <encu...@gmail.com> Co-authored-by: Meador Inge <mead...@gmail.com> Co-authored-by: Stan Ulbrych <89152624+stanfromirel...@users.noreply.github.com> files: M Doc/library/ctypes.rst diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index 8e74c6c9dee744..2ee4450698a107 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) - <Field type=c_long, ofs=0:0, bits=16> + <ctypes.CField 'first_16' type=c_int, ofs=0, bit_size=16, bit_offset=0> >>> print(Int.second_16) - <Field type=c_long, ofs=0:16, bits=16> - >>> + <ctypes.CField 'second_16' type=c_int, ofs=0, bit_size=16, bit_offset=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: _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: arch...@mail-archive.com