On this page
ctypes.addressof
Up: ctypes | Next: ctypes.alignment
Rel: ctypes.alignment, ctypes.ArgumentError, ctypes.Array, ctypes.BigEndianStructure
Ref: docs.python.org — ctypes.addressof
Tags: #public #python3 #stdlib #ctypes
Import
import ctypes
from ctypes import addressof
Signature & Overview
ctypes.addressof(obj, /)
Return the address of the C instance internal buffer
Usage
import ctypes
x = ctypes.c_int(42)
addr = ctypes.addressof(x)
assert isinstance(addr, int) and addr > 0
Gotchas
- Pointer stays valid only while
xis alive: Never keep raw integer addresses after the Python object is garbage-collected.
REPL Inspect
from ctypes import addressof
help(addressof)
Linked from
- tuts/python3/stdlib_module/ctypes
- tuts/python3/stdlib_module/ctypes/alignment
- tuts/python3/stdlib_module/ctypes/ArgumentError
- tuts/python3/stdlib_module/ctypes/Array
- tuts/python3/stdlib_module/ctypes/BigEndianStructure
- tuts/python3/stdlib_module/ctypes/BigEndianUnion
- tuts/python3/stdlib_module/ctypes/byref
- tuts/python3/stdlib_module/ctypes/c_bool
- tuts/python3/stdlib_module/ctypes/c_buffer
- tuts/python3/stdlib_module/ctypes/c_byte
- tuts/python3/stdlib_module/ctypes/c_char
- tuts/python3/stdlib_module/ctypes/c_char_p
- tuts/python3/stdlib_module/ctypes/c_double
- tuts/python3/stdlib_module/ctypes/c_double_complex
- tuts/python3/stdlib_module/ctypes/c_float
- tuts/python3/stdlib_module/ctypes/c_float_complex
- tuts/python3/stdlib_module/ctypes/c_int
- tuts/python3/stdlib_module/ctypes/c_int16
- tuts/python3/stdlib_module/ctypes/c_int32
- tuts/python3/stdlib_module/ctypes/c_int64
- tuts/python3/stdlib_module/ctypes/c_int8
- tuts/python3/stdlib_module/ctypes/c_long
- tuts/python3/stdlib_module/ctypes/c_longdouble
- tuts/python3/stdlib_module/ctypes/c_longdouble_complex
- tuts/python3/stdlib_module/ctypes/cast
- tuts/python3/stdlib_module/ctypes/create_string_buffer
- tuts/python3/stdlib_module/ctypes/create_unicode_buffer
- tuts/python3/stdlib_module/ctypes/get_errno
- tuts/python3/stdlib_module/ctypes/memmove
- tuts/python3/stdlib_module/ctypes/memoryview_at
- tuts/python3/stdlib_module/ctypes/memset
- tuts/python3/stdlib_module/ctypes/pointer
- tuts/python3/stdlib_module/ctypes/resize
- tuts/python3/stdlib_module/ctypes/set_errno
- tuts/python3/stdlib_module/ctypes/SetPointerType
- tuts/python3/stdlib_module/ctypes/sizeof
- tuts/python3/stdlib_module/ctypes/string_at
- tuts/python3/stdlib_module/ctypes/wstring_at
Related notes
- tuts/python3/stdlib_module/ctypes/alignment Linked here; links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/ArgumentError Linked here; links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/Array Linked here; links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/BigEndianStructure 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/BigEndianUnion links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/byref links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/c_bool links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/c_buffer links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/c_byte links to this page; shared tags: #ctypes, #stdlib