Module pyo3::ffi

source · []
Expand description

Raw FFI declarations for Python’s C API.

This module provides low level bindings to the Python interpreter. It is meant for advanced users only - regular PyO3 users shouldn’t need to interact with this module at all.

The contents of this module are not documented here, as it would entail basically copying the documentation from CPython. Consult the Python/C API Reference Manual for up-to-date documentation.

Safety

The functions in this module lack individual safety documentation, but generally the following apply:

  • Pointer arguments have to point to a valid Python object of the correct type, although null pointers are sometimes valid input.
  • The vast majority can only be used safely while the GIL is held.
  • Some functions have additional safety requirements, consult the Python/C API Reference Manual for more information.

Modules

Structs

Enums

Constants

METH_FASTCALLPy_3_10 or non-Py_LIMITED_API

Maximum number of dimensions

Set if the type allows subclassing

Objects support garbage collection (see objimp.h)

Py_TPFLAGS_HAVE_VECTORCALLPy_3_8 and non-Py_LIMITED_API

Set if the type implements the vectorcall protocol (PEP 590)

Objects support type attribute cache

Set if the type object is dynamically allocated

Set if the type is ‘ready’ – fully initialized

Set while the type is being ‘readied’, to prevent recursive ready calls

Statics

built-in ‘object’

built-in ‘super’

built-in ‘type’

Functions

Returns a pointer to a PyDateTime_CAPI instance

Check if op is a PyDateTimeAPI.DateTimeType or subtype.

Check if op’s type is exactly PyDateTimeAPI.DateTimeType.

Retrieve the fold component of a PyDateTime_DateTime. Returns a signed integer in the interval [0, 1]

Retrieve the hour component of a PyDateTime_DateTime. Returns a signed integer in the interval [0, 23]

Retrieve the microsecond component of a PyDateTime_DateTime. Returns a signed integer in the interval [0, 999999]

Retrieve the minute component of a PyDateTime_DateTime. Returns a signed integer in the interval [0, 59]

Retrieve the second component of a PyDateTime_DateTime. Returns a signed integer in the interval [0, 59]

Retrieve the tzinfo component of a PyDateTime_DateTime. Returns a pointer to a PyObject that should be either NULL or an instance of a datetime.tzinfo subclass.

Retrieve the days component of a PyDateTime_Delta.

Retrieve the seconds component of a PyDateTime_Delta.

Retrieve the seconds component of a PyDateTime_Delta.

Retrieve the day component of a PyDateTime_Date or PyDateTime_DateTime. Returns a signed integer in the interval [1, 31].

Retrieve the month component of a PyDateTime_Date or PyDateTime_DateTime. Returns a signed integer in the range [1, 12].

Retrieve the year component of a PyDateTime_Date or PyDateTime_DateTime. Returns a signed integer greater than 0.

Populates the PyDateTimeAPI object

Retrieve the fold component of a PyDateTime_Time. Returns a signed integer in the interval [0, 1]

Retrieve the hour component of a PyDateTime_Time. Returns a signed integer in the interval [0, 23]

Retrieve the microsecond component of a PyDateTime_DateTime. Returns a signed integer in the interval [0, 999999]

Retrieve the minute component of a PyDateTime_Time. Returns a signed integer in the interval [0, 59]

Retrieve the second component of a PyDateTime_DateTime. Returns a signed integer in the interval [0, 59]

Retrieve the tzinfo component of a PyDateTime_Time. Returns a pointer to a PyObject that should be either NULL or an instance of a datetime.tzinfo subclass.

Type Check macros

Check if op’s type is exactly PyDateTimeAPI.DateType.

Check if op is a PyDateTimeAPI.DetaType or subtype.

Check if op’s type is exactly PyDateTimeAPI.DeltaType.

PyFloat_AS_DOUBLENon-Py_LIMITED_API
PyGen_NeedsFinalizingDeprecatedNon-Py_3_9
PyHash_GetFuncDefNeither Py_LIMITED_API nor PyPy
PyImport_CleanupDeprecatedNon-Py_3_9
PyIndex_CheckNeither Py_LIMITED_API nor PyPy
PyIter_CheckNeither Py_LIMITED_API nor PyPy

Macro, trading safety for speed

Macro, only to be used to fill in brand new lists

PyModule_Create2Non-py_sys_config="Py_TRACE_REFS"
PyModule_FromDefAndSpec2Non-py_sys_config="Py_TRACE_REFS"
PyModule_GetFilenameDeprecatedNot (Windows and PyPy)
PyOS_InitInterruptsDeprecatedNon-Py_3_10
PyObject_CallNoArgsNon-PyPy and (non-Py_LIMITED_API or Py_3_9)
PyObject_CallOneArgPy_3_8 and non-PyPy
PyObject_CheckBufferNeither Py_3_9 nor PyPy
PyObject_GenericGetDictNot (Py_LIMITED_API and non-Py_3_10)
PyObject_IS_GCNon-Py_LIMITED_API

Test if an object has a GC head

PyObject_VectorcallPy_3_8 and non-PyPy
PyParser_SimpleParseFileNon-Py_LIMITED_API and non-Py_3_10
PyParser_SimpleParseStringNon-Py_LIMITED_API and non-Py_3_10
PyStructSequence_GET_ITEMNeither Py_LIMITED_API nor PyPy
PyStructSequence_SET_ITEMNeither Py_LIMITED_API nor PyPy

Check if op is a PyDateTimeAPI.TZInfoType or subtype.

Check if op’s type is exactly PyDateTimeAPI.TZInfoType.

Check if op is a PyDateTimeAPI.TimeType or subtype.

Check if op’s type is exactly PyDateTimeAPI.TimeType.

Macro, trading safety for speed

Macro, only to be used to fill in brand new tuples

PyType_HasFeatureNon-Py_LIMITED_API

Test if a type has a GC head

PyType_SUPPORTS_WEAKREFSNon-Py_LIMITED_API

Test if a type supports weak references

PyUnicode_AsUTF8AndSizePy_3_10 or non-Py_LIMITED_API
PyUnicode_AsUnicodeDeprecatedNon-Py_3_12
PyUnicode_AsUnicodeAndSizeDeprecatedNon-Py_3_12
PyUnicode_DATALittle-endian
PyUnicode_FromUnicodeDeprecatedNon-Py_3_12
PyUnicode_KINDLittle-endian
PyUnicode_READYNon-Py_3_12 and little-endian
PyVectorcall_FunctionPy_3_8 and non-PyPy
PyVectorcall_NARGSPy_3_8 and non-PyPy
Py_CompileStringObjectNon-Py_LIMITED_API
Py_SymtableStringNeither PyPy nor Py_3_10
Py_SymtableStringObjectNeither Py_LIMITED_API nor Py_3_10 nor PyPy
_PyObject_CallNoArgPy_3_8 and non-PyPy
_PyObject_FastCallPy_3_8 and non-PyPy
_PyObject_FastCallTstatePy_3_8 and non-PyPy
_PyObject_GC_CallocNon-Py_LIMITED_API
_PyObject_GC_MallocNon-Py_LIMITED_API
_PyObject_MakeTpCallPy_3_8 and non-PyPy
_PySet_NextEntryNon-Py_LIMITED_API
_PyStack_AsDictPy_3_8 and non-PyPy
_Py_CheckFunctionResultPy_3_8 and non-PyPy
_Py_GetAllocatedBlocksNon-Py_LIMITED_API
_Py_HashBytesNeither Py_LIMITED_API nor PyPy

Type Definitions

Unions

Function types used to implement Python callables.