Runtime Types

types.CapsuleType — runtime type

Identifies opaque PyCapsule objects used to exchange native C-level pointers through extension APIs. Python code can recognize the object but should not treat it as an ordinary memory buffer, dereference it or create arbitrary pointers. The example inspects the datetime C API capsule without accessing its contents.

Formal Syntax & Structure

python syntaxpython
types.CapsuleType

Return Value

type

The class object types.CapsuleType; this reference documents the class identity, not a universal constructor signature.

Working Example

Example Snippetpython
import typesimport datetimevalue = datetime.datetime_CAPIprint(isinstance(value, types.CapsuleType))
Python Reference