Module pyo3::ffi[][src]

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

Maximum number of dimensions

Set if the type allows subclassing

Objects support garbage collection (see objimp.h)

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’

Safe wrapper around the Python datetime C-API global. Note that this object differs slightly from the equivalent C object: in C, this is implemented as a static PyDateTime_CAPI *. Here this is implemented as a wrapper which implements Deref to access a reference to a PyDateTime_CAPI object.

Safe wrapper around the Python C-API global PyDateTime_TimeZone_UTC. This follows a similar strategy as PyDateTimeAPI: the Python datetime C-API will automatically be imported if this type is deferenced.

built-in ‘super’

built-in ‘type’

Functions

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.

Macro, trading safety for speed

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

Test if an object has a GC head

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

Test if a type has a GC head

Test if a type supports weak references

Type Definitions