diff --git a/python/src/nanoarrow/_array.pyi b/python/src/nanoarrow/_array.pyi index 5f187b17f..aa3d8a71e 100644 --- a/python/src/nanoarrow/_array.pyi +++ b/python/src/nanoarrow/_array.pyi @@ -101,12 +101,21 @@ class CArrayBuilder: validation if possible. Validation may not be possible if children were set that were not created by nanoarrow. """ + def finish_device(self, *args, **kwargs): + """Finish building this array and export to an ArrowDeviceArray + + Calls :meth:`finish`, propagating device information into an ArrowDeviceArray. + """ def init_from_schema(self, *args, **kwargs): ... def init_from_type(self, *args, **kwargs): ... def is_empty(self, *args, **kwargs): """Check if any items have been appended to this builder""" def resolve_null_count(self, *args, **kwargs): - """Ensure the output null count is synchronized with existing buffers""" + """Ensure the output null count is synchronized with existing buffers + + Note that this will not attempt to access non-CPU buffers such that + :attr:`null_count` might still be -1 after calling this method. + """ def set_buffer(self, *args, **kwargs): """Set an ArrowArray buffer diff --git a/python/src/nanoarrow/_buffer.pyi b/python/src/nanoarrow/_buffer.pyi index d6e6665a9..aed132897 100644 --- a/python/src/nanoarrow/_buffer.pyi +++ b/python/src/nanoarrow/_buffer.pyi @@ -29,6 +29,7 @@ class CBuffer: __pyx_vtable__: ClassVar[PyCapsule] = ... data_type: Incomplete data_type_id: Incomplete + device: Incomplete element_size_bits: Incomplete format: Incomplete itemsize: Incomplete @@ -40,9 +41,47 @@ class CBuffer: def element(self, *args, **kwargs): ... def elements(self, *args, **kwargs): ... @staticmethod - def empty(*args, **kwargs): ... + def empty(*args, **kwargs): + """Create an empty CBuffer""" + @staticmethod + def from_dlpack(*args, **kwargs): + """Create a CBuffer using the DLPack protocol + + Wraps a tensor from an external library as a CBuffer that can be used + to create an array. + + Parameters + ---------- + obj : object with a ``__dlpack__`` attribute + The object on which to invoke the DLPack protocol + stream : int, optional + The stream on which the tensor represented by obj should be made + safe for use. This value is passed to the object's ``__dlpack__`` + method; however, the CBuffer does not keep any record of this (i.e., + the caller is responsible for creating a sync event after creating one + or more buffers in this way). + """ @staticmethod - def from_pybuffer(*args, **kwargs): ... + def from_pybuffer(*args, **kwargs): + """Create a CBuffer using the Python buffer protocol + + Wraps a buffer using the Python buffer protocol as a CBuffer that can be + used to create an array. + + Parameters + ---------- + obj : buffer-like + The object on which to invoke the Python buffer protocol + """ + def view(self, *args, **kwargs): + """Export this buffer as a CBufferView + + Returns a :class:`CBufferView` of this buffer. After calling this + method, the original CBuffer will be invalidated and cannot be used. + In general, the view of the buffer should be used to consume a buffer + (whereas the CBuffer is primarily used to wrap an existing object in + a way that it can be used to build a :class:`CArray`). + """ def __buffer__(self, *args, **kwargs): """Return a buffer object that exposes the underlying memory of the object.""" def __getitem__(self, index): @@ -147,7 +186,7 @@ class CBufferView: Parameters ---------- stream : int, optional - A Python integer representing a pointer to a stream. Currently not supported. + A Python integer representing a pointer to a stream. Stream is provided by the consumer to the producer to instruct the producer to ensure that operations can safely be performed on the array. diff --git a/python/src/nanoarrow/_device.pyi b/python/src/nanoarrow/_device.pyi index c7c56bea2..4d2c20794 100644 --- a/python/src/nanoarrow/_device.pyi +++ b/python/src/nanoarrow/_device.pyi @@ -25,6 +25,13 @@ __reduce_cython__: _cython_3_0_11.cython_function_or_method __setstate_cython__: _cython_3_0_11.cython_function_or_method __test__: dict +class CSharedSyncEvent: + __pyx_vtable__: ClassVar[PyCapsule] = ... + @classmethod + def __init__(cls, *args, **kwargs) -> None: + """Create and return a new object. See help(type) for accurate signature.""" + def __reduce__(self): ... + class Device: device_id: Incomplete device_type: Incomplete @@ -34,6 +41,18 @@ class Device: """Create and return a new object. See help(type) for accurate signature.""" @staticmethod def resolve(*args, **kwargs): ... + def __eq__(self, other: object) -> bool: + """Return self==value.""" + def __ge__(self, other: object) -> bool: + """Return self>=value.""" + def __gt__(self, other: object) -> bool: + """Return self>value.""" + def __le__(self, other: object) -> bool: + """Return self<=value.""" + def __lt__(self, other: object) -> bool: + """Return self bool: + """Return self!=value.""" def __reduce__(self): ... class DeviceType(enum.Enum): diff --git a/python/src/nanoarrow/_ipc_lib.pyi b/python/src/nanoarrow/_ipc_lib.pyi index 58c1ea64b..620dcba4a 100644 --- a/python/src/nanoarrow/_ipc_lib.pyi +++ b/python/src/nanoarrow/_ipc_lib.pyi @@ -33,7 +33,29 @@ class CIpcInputStream: def release(self, *args, **kwargs): ... def __reduce__(self): ... -class PyInputStreamPrivate: +class CIpcOutputStream: + @classmethod + def __init__(cls, *args, **kwargs) -> None: + """Create and return a new object. See help(type) for accurate signature.""" + @staticmethod + def from_writable(*args, **kwargs): ... + def is_valid(self, *args, **kwargs): ... + def release(self, *args, **kwargs): ... + def __reduce__(self): ... + +class CIpcWriter: + @classmethod + def __init__(cls, *args, **kwargs) -> None: + """Create and return a new object. See help(type) for accurate signature.""" + def is_valid(self, *args, **kwargs): ... + def release(self, *args, **kwargs): ... + def write_array_stream(self, *args, **kwargs): ... + def write_array_view(self, *args, **kwargs): ... + def write_end_of_stream(self, *args, **kwargs): ... + def write_schema(self, *args, **kwargs): ... + def __reduce__(self): ... + +class PyStreamPrivate: close_obj: Incomplete obj: Incomplete @classmethod