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
- structmemberDeprecated
Structs
- Structure representing a
datetime.date
- Structure representing a
datetime.datetime
. - Structure representing a
datetime.timedelta
. - Structure representing a
datetime.time
. - Represents the PyGetSetDef structure.
- Represents the PyMemberDef structure.
- Represents the PyMethodDef structure.
- Structure representing a
datetime.datetime
without atzinfo
member. - Structure representing a
datetime.time
without atzinfo
member.
Enums
Constants
- Maximum number of dimensions
- PyUnicode_WCHAR_KINDDeprecated
- Set if the type allows subclassing
- Objects support garbage collection (see objimp.h)
- Set if the type implements the vectorcall protocol (PEP 590)
- 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
- _Py_T_NONEDeprecated
- _Py_T_OBJECTDeprecated
- _Py_WRITE_RESTRICTEDDeprecated
Statics
- built-in ‘object’
- built-in ‘super’
- built-in ‘type’
- Py_BytesWarningFlagDeprecated
- Py_DebugFlagDeprecated
- Py_DontWriteBytecodeFlagDeprecated
- Py_FileSystemDefaultEncodeErrorsDeprecated
- Py_FileSystemDefaultEncodingDeprecated
- Py_FrozenFlagDeprecated
- Py_HasFileSystemDefaultEncodingDeprecated
- Py_IgnoreEnvironmentFlagDeprecated
- Py_InspectFlagDeprecated
- Py_InteractiveFlagDeprecated
- Py_IsolatedFlagDeprecated
- Py_NoSiteFlagDeprecated
- Py_NoUserSiteDirectoryDeprecated
- Py_OptimizeFlagDeprecated
- Py_QuietFlagDeprecated
- Py_UnbufferedStdioFlagDeprecated
- Py_UseClassExceptionsFlagDeprecated
- Py_VerboseFlagDeprecated
Functions
- Returns a pointer to a
PyDateTime_CAPI
instance - Check if
op
is aPyDateTimeAPI.DateTimeType
or subtype. - Check if
op
’s type is exactlyPyDateTimeAPI.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 aPyObject
that should be either NULL or an instance of adatetime.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
orPyDateTime_DateTime
. Returns a signed integer in the interval[1, 31]
. - Retrieve the month component of a
PyDateTime_Date
orPyDateTime_DateTime
. Returns a signed integer in the range[1, 12]
. - Retrieve the year component of a
PyDateTime_Date
orPyDateTime_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 aPyObject
that should be either NULL or an instance of adatetime.tzinfo
subclass. - Type Check macros
- Check if
op
’s type is exactlyPyDateTimeAPI.DateType
. - Check if
op
is aPyDateTimeAPI.DetaType
or subtype. - Check if
op
’s type is exactlyPyDateTimeAPI.DeltaType
. - PyGen_NeedsFinalizing⚠Deprecated
- PyImport_Cleanup⚠Deprecated
- Macro, trading safety for speed
- Macro, only to be used to fill in brand new lists
- PyModule_GetFilename⚠Deprecated
- PyOS_AfterFork⚠Deprecated
- PyOS_InitInterrupts⚠Deprecated
- Check if
op
is aPyDateTimeAPI.TZInfoType
or subtype. - Check if
op
’s type is exactlyPyDateTimeAPI.TZInfoType
. - Check if
op
is aPyDateTimeAPI.TimeType
or subtype. - Check if
op
’s type is exactlyPyDateTimeAPI.TimeType
. - Macro, trading safety for speed
- Macro, only to be used to fill in brand new tuples
- PyUnicode_AsUnicode⚠Deprecated
- PyUnicode_AsUnicodeAndSize⚠Deprecated
- PyUnicode_FromUnicode⚠Deprecated
- PyUnicode_GetSize⚠Deprecated
Type Definitions
Unions
- Function types used to implement Python callables.