Ctypes helpers for DLPack interop
Project description
ctypes-dlpack
The DLPack standard allows to share
arrays/tensors data between different frameworks. It is defined as a C API, and
the standard way to use it from Python is the __dlpack__ protocol defined in
the array
api,
which relies on PyCapsule to pass the pointer around through Python code.
However, there might be times where one does not have a PyCapsule but just a
raw pointer to the DLPack C struct. In particular, this might be the case when
adding bindings to a C library through ctypes instead of going through a
CPython extension module. This library is here to bridge this gap, creating
ctypes pointers from the __dlpack__ protocol, and making existing pointers
compatible with this protocol.
This library exposes both the C structs/enums/constants from the DLPack C header
as ctypes types (containing among other the version of the DLPack library
that was used to generate the ctypes declarations), and a Python API to convert
between DLPack pointers and Python objects. See the documentation for more details.
You can install the code with pip install ctypes-dlpack.
License and contributions
This project is distributed under the terms of the BSD license, and maintained by @Luthaf, who will reply to issues and pull requests opened on this repository as soon as possible. You can mention them directly if you did not receive an answer after a couple of days.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ctypes_dlpack-0.1.0.tar.gz.
File metadata
- Download URL: ctypes_dlpack-0.1.0.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1f8811e761f05bc28aa60cab2674afe4f6c7242255987214776cfc04c605132
|
|
| MD5 |
6d1f7a81125e62c8b6dc2a5fb4a23a49
|
|
| BLAKE2b-256 |
3dedb6e68eba9f6df3df1c3bbd93ef5af2cd7156c9ef1e35abf0d7c06b923e0f
|
File details
Details for the file ctypes_dlpack-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ctypes_dlpack-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32c16522868e978bbbf1de3010e57960a810f0ba1628cfcf8bcb5b2e25fd14db
|
|
| MD5 |
f1a3f713902e1a2207769856897397ff
|
|
| BLAKE2b-256 |
9db80719443f8b63536ba4dcb315864082f89a5e789089db941897232ad6b14e
|