Path: blob/main/py-polars/tests/unit/utils/pycapsule_utils.py
8412 views
from typing import Any123class PyCapsuleStreamHolder:4"""5Hold the Arrow C Stream pycapsule.67A class that exposes the Arrow C Stream interface via Arrow PyCapsules. This8ensures that the consumer is seeing _only_ the `__arrow_c_stream__` dunder, and that9nothing else (e.g. the dataframe or array interface) is actually being used.10"""1112arrow_obj: Any1314def __init__(self, arrow_obj: object) -> None:15self.arrow_obj = arrow_obj1617def __arrow_c_stream__(self, requested_schema: object = None) -> object:18return self.arrow_obj.__arrow_c_stream__(requested_schema)1920def __iter__(self) -> None:21return2223def __next__(self) -> None:24return252627class PyCapsuleArrayHolder:28"""29Hold the Arrow C Array pycapsule.3031A class that exposes _only_ the Arrow C Array interface via Arrow PyCapsules. This32ensures that the consumer is seeing _only_ the `__arrow_c_array__` dunder, and that33nothing else (e.g. the dataframe or array interface) is actually being used.34"""3536arrow_obj: Any3738def __init__(self, arrow_obj: object) -> None:39self.arrow_obj = arrow_obj4041def __arrow_c_array__(self, requested_schema: object = None) -> object:42return self.arrow_obj.__arrow_c_array__(requested_schema)434445