Path to the shared library, or null to load the current process
(Linux and macOS; on Windows null throws TypeError
LoadLibrary() argument 1 must be str, not None unless options.handle is given, as in CPython).
A name with a NUL character is a RangeError (embedded null character on
Windows, embedded null byte elsewhere; Python ValueError). On Windows,
"" throws Error [WinError 87] <system text> (winerror 87, as
CPython's OSError), and a library that cannot be found throws Error
Could not find module '<name>' (or one of its dependencies). Try using the full path with constructor syntax. with errno 2 (CPython:
FileNotFoundError).
Optionaloptions: number | LibraryOptions
dlopen mode (as Python's CDLL(name, mode)) or library
settings (mode, cache size, use_last_error, use_errno)
ReadonlypathLibrary file path.
Readonly_Python ctypes lib._name: the name passed to the constructor (null for the current process).
Readonly_Native OS module handle address (lib._handle); it stays the same after
close(). With an explicit LibraryOptions.handle it is the value
given, as a BigInt with its sign (-1n for handle: -1, as CPython).
ReadonlyloadedWhether the logical handle is open, independently of physical module residency.
Typed overload: narrows args/return when argTypes is a literal tuple.
Optionaloptions: FunctionOptionsTyped overload: narrows args/return when argTypes is a literal tuple.
Typed overload: narrows args/return when argTypes is a literal tuple.
OptionalargTypes: FFIType[]Optionaloptions: FunctionOptionsGet the address of a symbol.
Symbol name
Address as BigInt
Close the library and clear the function cache. Functions obtained from
it throw when called afterwards. Throws while a call to one of its
functions is in progress (from a callback, or a pending callAsync()).
Existing in_dll() views defer native handle release until their dependent
memory is collected, but new calls and symbol lookups are rejected.
Physical unloading depends on the OS loader; musl keeps modules resident.
Close the library at the end of a using block.
The thread's ctypes-private copy of GetLastError() (Windows), the same
value as the global get_last_error (a signed C int): functions
created with use_last_error swap it with the system value around each call.
A Node extension (Python has only the global): it throws Error
Library was not opened with use_last_error: true unless the library was
opened with LibraryOptions.use_last_error.
Python ctypes parity: ctypes.get_last_error().
The thread's ctypes-private copy of errno, the same value as the global
get_errno: functions created with use_errno swap it with the
system value around each call. A Node extension: it throws Error
Library was not opened with use_errno: true unless the library was
opened with LibraryOptions.use_errno.
Python ctypes parity: ctypes.get_errno().
Python lib[name]: a new function for the C export name, also when a
library member has the same name (lib.__getitem__("close") is the C
close). Throws an error named AttributeError when the export is missing.
An integer (Number, BigInt or boolean) is an export ordinal on Windows
(Python lib[1]; JS lib[1] is the name "1", so use __getitem__):
it is masked to 16 bits, a missing one throws AttributeError
function ordinal N not found, and the function has no __name__.
Other values throw TypeError
function name must be string, bytes object or integer.
Python-like function access. Accessing any property returns a FunctionWrapper that supports
argtypes/restypeassignment.name in libis true for the exports that resolve; reading a missing export throws an error namedAttributeError.