Skip to main content

ctypes but usable

Project description

dtypes

Yo yo what's this?

Well it's ✨dtypes✨ which is extra stuff to make ctypes usable. Or as the my future kids like to say, "dtypes is on ctypes like butter is on toast".

Who wants to do

class Yolo(ctypes.structure):
    _fields_ = [
        ("a", ctypes.c_int),
        ("b", ctypes.c_float),
        ("c", ctypes.c_double),
    ]

when you can do

from dtypes.structify import structify

@structify
class Yolo(ctypes.structure):
    a : ctypes.c_int
    b : ctypes.c_float
    c : ctypes.c_double

And then, who wants to deal with the messy and incomplete way of working with forward declarations in pure ctypes?

class Yeet(ctypes.structure):
    pass

class Chonko(ctypes.structure):
    _fields_ = [
        ("yeet", ctypes.POINTER(Yeet)),
    ]

Yeet._fields_ =[
    ("chonker", Chonko),
    ("this", ctypes.POINTER(Yeet),
]

when you can do

from dtypes.structify import structify
from dtypes.fwd import fwd, ThisPtr, Pointer

Yeet = fwd()

@structify
class Chonko(ctypes.structure):
    yeet : Pointer(Yeet)

@structify
class Yeet(ctypes.structure, Yeet):
    chonker : Chonko
    this    : ThisPtr
]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dtypes-0.0.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

dtypes-0.0.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file dtypes-0.0.1.tar.gz.

File metadata

  • Download URL: dtypes-0.0.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for dtypes-0.0.1.tar.gz
Algorithm Hash digest
SHA256 8f437ffb69605301a68adec6327e165e8c53892bfb13734b4a5f5b123bdab391
MD5 168292bf34d488eb28beb28e002d7eb8
BLAKE2b-256 a15449fffeed2831b2c78cad1efd6abf4e06e0af85ffb365bb6e0bc380e2db73

See more details on using hashes here.

File details

Details for the file dtypes-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: dtypes-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for dtypes-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 469d6f7a9fbaf733adae589142e2311077dc870687867f72b1d36d11d718d649
MD5 083d3bd78c6661a1853e8bcda609c0e1
BLAKE2b-256 09a6397d3b1e0e4ece7e614f7dacbed33b6dd2afc4c06554954d42b60b08d262

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page