Skip to main content

exactypes

Helps creating typed ctypes-based python library.

Code examples can be found in examples.

Installation

Use pip or whatever package/project managers to install:

pip install exactypes

Features

Better typing support for functions

Defining external functions more conveniently with annotations.

>>> from exactypes import ccall, argtypes as A, restype as R
>>> from ctypes import CDLL
>>> libc = CDLL("libc.so.6")  # find your own library
>>> @ccall(libc)
... def printf(fmt: A.c_char_p, *args: A.VaArgs) -> R.c_int:
...     pass
... 
>>> printf("The answer is %d.\n", 42)
The answer is 42.
18

Better typing support for structures and unions

Defining structures and/or unions like dataclasses.

>>> import ctypes
>>> import typing
>>> from exactypes import Ptr, cstruct
>>> from exactypes import datafield as D
>>> IntArr_8 = typing.Annotated[D.array_of("c_int"), 8]
>>> @cstruct
... class Example(ctypes.Structure):
...     a: D.c_int = D.value()
...     _padding: typing.ClassVar[D.c_int]
...     b: D.c_double = D.value()
...     m: Ptr["Example"] = D.value()
...     n: IntArr_8 = D.value()
... 
>>> a = Example(123, 246, Ptr())
>>> a.m = Ptr(a)
>>> a.m.contents.m.contents.b
246.0
>>> a.n[:]
[0, 0, 0, 0, 0, 0, 0, 0]

Better array interface

Playing with arrays.

>>> from exactypes import array
>>> a = array.of("c_int")(range(10))
>>> a[:]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Metadata

Release files for exactypes 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for exactypes 0.4.0
File Size Uploaded Provenance Actions
exactypes-0.4.0.tar.gz 16.4 kB With provenance Details for exactypes-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for exactypes 0.4.0
File Interpreter ABI Platform Actions
exactypes-0.4.0-py3-none-any.whl Python 3 none any Details for exactypes-0.4.0-py3-none-any.whl

Total release size: 35.8 kB

Release files / exactypes-0.4.0.tar.gz

Download URL exactypes-0.4.0.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6b0b177cdbcd02e7c22caab29a583eee2eff22757aa6fb98b6cc3a2339bfad19
BLAKE2b-256 checksum
How to use checksums
571187b3eb5f9a36c4d196e11db9553e1906be1e8a3393d0dc687f8aceae68e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 11, 2025.

Transparency log

Release files / exactypes-0.4.0-py3-none-any.whl

Download URL exactypes-0.4.0-py3-none-any.whl
Size 19.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ed839195de945b725eea97475ba78db16ed5199b4b95c7fca2b9d461e77ee7e
BLAKE2b-256 checksum
How to use checksums
e7903ff6918ee995f5832db5c0b61e529ee761aff763a5e0b187cbfacec9c56b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 11, 2025.

Transparency log

Security for exactypes 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for exactypes-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 11, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page