Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/py-polars/tests/unit/utils/pycapsule_utils.py
8412 views
1
from typing import Any
2
3
4
class PyCapsuleStreamHolder:
5
"""
6
Hold the Arrow C Stream pycapsule.
7
8
A class that exposes the Arrow C Stream interface via Arrow PyCapsules. This
9
ensures that the consumer is seeing _only_ the `__arrow_c_stream__` dunder, and that
10
nothing else (e.g. the dataframe or array interface) is actually being used.
11
"""
12
13
arrow_obj: Any
14
15
def __init__(self, arrow_obj: object) -> None:
16
self.arrow_obj = arrow_obj
17
18
def __arrow_c_stream__(self, requested_schema: object = None) -> object:
19
return self.arrow_obj.__arrow_c_stream__(requested_schema)
20
21
def __iter__(self) -> None:
22
return
23
24
def __next__(self) -> None:
25
return
26
27
28
class PyCapsuleArrayHolder:
29
"""
30
Hold the Arrow C Array pycapsule.
31
32
A class that exposes _only_ the Arrow C Array interface via Arrow PyCapsules. This
33
ensures that the consumer is seeing _only_ the `__arrow_c_array__` dunder, and that
34
nothing else (e.g. the dataframe or array interface) is actually being used.
35
"""
36
37
arrow_obj: Any
38
39
def __init__(self, arrow_obj: object) -> None:
40
self.arrow_obj = arrow_obj
41
42
def __arrow_c_array__(self, requested_schema: object = None) -> object:
43
return self.arrow_obj.__arrow_c_array__(requested_schema)
44
45