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§
- C API Compatibility Shims
- structmember
Deprecated
Macros§
- This is a helper macro to create a
&'static CStr
.
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_ KIND Deprecated - 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_ NONE Deprecated - _Py_
T_ OBJECT Deprecated - _Py_
WRITE_ RESTRICTED Deprecated
Statics§
- built-in ‘object’
- built-in ‘super’
- built-in ‘type’
- Py_
Bytes Warning Flag Deprecated - Py_
Debug Flag Deprecated - Py_
Dont Write Bytecode Flag Deprecated - Py_
File System Default Encode Errors Deprecated - Py_
File System Default Encoding Deprecated - Py_
Frozen Flag Deprecated - Py_
HasFile System Default Encoding Deprecated - Py_
Ignore Environment Flag Deprecated - Py_
Inspect Flag Deprecated - Py_
Interactive Flag Deprecated - Py_
Isolated Flag Deprecated - Py_
NoSite Flag Deprecated - Py_
NoUser Site Directory Deprecated - Py_
Optimize Flag Deprecated - Py_
Quiet Flag Deprecated - Py_
Unbuffered Stdio Flag Deprecated - Py_
UseClass Exceptions Flag Deprecated - Py_
Verbose Flag Deprecated
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_
Needs ⚠Finalizing Deprecated - PyImport_
Cleanup ⚠Deprecated - Macro, trading safety for speed
- Macro, only to be used to fill in brand new lists
- PyModule_
GetFilename ⚠Deprecated - PyOS_
After ⚠Fork Deprecated - PyOS_
Init ⚠Interrupts 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_
AsUnicode ⚠AndSize Deprecated - PyUnicode_
From ⚠Unicode Deprecated - PyUnicode_
GetSize ⚠Deprecated
Type Aliases§
- _PyC
Function Fast Deprecated - _PyC
Function Fast With Keywords Deprecated
Unions§
- Function types used to implement Python callables.