Skip to main content

Ctypes wrapper for easier Python interoperability with Fortran and C

Project description

FancyTypes

Syntax sugar for ctypes that provides a more confortable way to load and setup shared libraries for your projects. The goal of this simple package is to reduce boilerplate and replace tedious syntax with something more intuitive and fancier.

Features

  • Load shared libraries and only interface the desired procedures.
  • Parse argument and result types together through a dedicated parser function.
  • Multiple type aliases available (e.g. real64 / float64 for 64-bit floating point numbers)
  • Improved syntax to define C struct and union types
  • Tools to work with NumPy arrays

All ctypes types are compatible even if FancyTypes does not provide its own specific class for them. For example, char support is limited since the main focus of the package is numerical computing, so syntax improvements to pass strings around are limited to turning them into NumPy arrays and not much else. Typically, strings and I/O can be handled on the Python side.

Dependency free

The only dependency is NumPy for array handling. The NumPy package is pretty much part of the standard library amongst the Python numerical computing ecosystem, so any project that could potentially use this will most likely already depend on NumPy on its own.

Documentation

Read the documentation and find out if this package could be useful to you (in progress).

Installation and importing

The package can be installed from PyPI

pip install fancy-ctypes

Alternatively, download this repository and run

pip install .

The package is imported as

import fancytypes

# For confort
import fancytypes as ft

Platform

The package is intended to be platform agnostic, although shared libraries are not. This is a tool that interfaces those libraries with Python, but users still need to build them first however they want.

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

fancy_ctypes-0.2.0.tar.gz (49.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fancy_ctypes-0.2.0-py3-none-any.whl (39.2 kB view details)

Uploaded Python 3

File details

Details for the file fancy_ctypes-0.2.0.tar.gz.

File metadata

  • Download URL: fancy_ctypes-0.2.0.tar.gz
  • Upload date:
  • Size: 49.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for fancy_ctypes-0.2.0.tar.gz
Algorithm Hash digest
SHA256 37aa0bc950d6cbd83f2de1a63260c1b547b05f3f1efe3bb8806d13766e4b03eb
MD5 92d522777fc1d0618a15e3c63e734906
BLAKE2b-256 909939d9ed4eff4f6661286ad453b63d755c824c0dc1e53e37e07ca0c30c2629

See more details on using hashes here.

File details

Details for the file fancy_ctypes-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: fancy_ctypes-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 39.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for fancy_ctypes-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f2c2fe585de4cec682732ab3ec1a8501758c96cbd0c178789eefa7d7cdfccfc
MD5 7887173f25415c96d0cf11d1550cb9ed
BLAKE2b-256 7c0c6264777d25d3f6432c93bbbd6ed3a7fa94afe9e74413cd2b96dee0b1ba89

See more details on using hashes here.

Supported by

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