All Projects → idlesign → ctyped

idlesign / ctyped

Licence: BSD-3-Clause license
Build ctypes interfaces for shared libraries with type hinting

Programming Languages

python
139335 projects - #7 most used programming language
c
50402 projects - #5 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to ctyped

prodict
Prodict, what Python dict meant to be.
Stars: ✭ 102 (+500%)
Mutual labels:  typehinting

ctyped

https://github.com/idlesign/ctyped

release lic ci coverage

Description

Build ctypes interfaces for shared libraries with type hinting

Requires Python 3.6+

  • Less boilerplate;
  • Logical structuring;
  • Basic code generator (.so function -> ctyped function);
  • Useful helpers.
from ctyped.toolbox import Library

# Define library.
lib = Library('mylib.so')

@lib.structure
class Box:

    one: int
    two: str

# Type less with function names prefixes.
with lib.scope(prefix='mylib_'):

    # Describe function available in the library.
    @lib.function
    def some_func(title: str, year: int, box: Box) -> str:
        ...

# Bind ctype types to functions available in the library.
lib.bind_types()

# Call library function.
result_string = some_func('Hello!', 2019, Box(one=35, two='dummy'))

Read the documentation for more information.

Documentation

http://ctyped.readthedocs.org/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].