On this page
ctypes.byref
Prev: ctypes.BigEndianUnion | Up: ctypes | Next: ctypes.c_bool
Rel: ctypes.addressof, ctypes.alignment, ctypes.ArgumentError, ctypes.Array
Ref: docs.python.org — ctypes.byref
Tags: #public #python3 #stdlib #ctypes
Import
import ctypes
from ctypes import byref
Signature & Overview
ctypes.byref(obj, offset=0, /)
Return a pointer lookalike to a C instance, only usable as function argument.
Usage
import ctypes
x = ctypes.c_int(5)
ref = ctypes.byref(x)
assert ref is not None
Gotchas
- Faster than
pointer(x)when passing an out-parameter to C: Doesn't build a full PythonPOINTERwrapper; supportsoffset=.
REPL Inspect
from ctypes import byref
help(byref)
Linked from
Related notes
- tuts/python3/stdlib_module/ctypes/BigEndianUnion Linked here; links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/c_bool Linked here; links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/ctypes/addressof Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/alignment Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/ArgumentError Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/Array Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/BigEndianStructure shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/c_buffer shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/c_byte shared tags: #ctypes, #stdlib