File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
src/array_api_stubs/_draft Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,18 @@ page gives a high-level specification for data exchange in Python using DLPack.
8585 below. They are not required to return an array object from ``from_dlpack ``
8686 which conforms to this standard.
8787
88+
89+ DLPack C Exchange API
90+ ---------------------
91+
92+ DLPack 1.3 introduces a C-level exchange API that can be used to speed up
93+ data exchange between arrays at the C-extension level. This API is available via
94+ the ``type(array_instance).__dlpack_c_exchange_api__ `` attribute on the array type object.
95+ For more details, see the `Python specification of DLPack <https://dmlc.github.io/dlpack/latest/python_spec.html >`__
96+ We recommend consumer libraries to start first using the python level ``__dlpack__ `` first which will covers
97+ most cases, then start to use the C-level ``__dlpack_c_exchange_api__ `` for performance critical cases.
98+
99+
88100Non-supported use cases
89101-----------------------
90102
Original file line number Diff line number Diff line change 1717
1818
1919class _array :
20+ """
21+ Attributes
22+ ----------
23+ __dlpack_c_exchange_api__: PyCapsule
24+ An optional static array type attribute store in ``type(array_instance).__dlpack_c_exchange_api__``
25+ that can be used to retrieve the DLPack C-API exchange API struct in DLPack 1.3 or later to speed up
26+ exchange of array data at the C extension level without going through Python-level exchange.
27+ See :ref:`data-interchange` section for more details.
28+ """
29+ # use None for placeholder
30+ __dlpack_c_exchange_api__ : PyCapsule = None
31+
2032 def __init__ (self : array ) -> None :
2133 """Initialize the attributes for the array object class."""
2234
You can’t perform that action at this time.
0 commit comments