cint - ctypes Integer Aliases
cint provides Python 2.7 aliases for `ctypes` integer types, aiming to simplify their use. It wraps C integer types (e.g., `int8`, `uint32`) directly from the `ctypes` module. The library is currently at version 1.0.0, with no active development since 2017, indicating an abandoned status.
Warnings
- breaking This library is primarily designed for and tested with Python 2.7. While its PyPI metadata indicates compatibility with Python 3.4+, the codebase uses Python 2.7 print syntax and other idioms that will cause syntax errors or runtime issues in Python 3. It will not work correctly without significant manual porting.
- gotcha The `cint` project has been abandoned since 2017. There will be no further updates, bug fixes, or security patches. It is not recommended for new projects.
- gotcha `cint` essentially provides aliases to `ctypes` types. For example, `cint.int8` is `ctypes.c_byte`. Its primary value was syntactic sugar for Python 2.7 users. Modern Python code can easily use `ctypes` directly without this wrapper.
Install
-
pip install cint
Imports
- int8
from cint import int8
- uint32
from cint import uint32
- char_p
from cint import char_p
Quickstart
# This example is intended for Python 2.7. # The `cint` library provides convenient aliases for ctypes integer types. # For Python 3, it's recommended to use `ctypes` directly. from cint import int32, uint16 # Create a signed 32-bit integer using cint's alias my_signed_int = int32(-100) print "Value:", my_signed_int.value print "Python type of value:", type(my_signed_int.value) print "Actual ctypes type:", type(my_signed_int) # This will show the actual ctypes type # Create an unsigned 16-bit integer my_unsigned_int = uint16(65530) print "Value:", my_unsigned_int.value print "Python type of value:", type(my_unsigned_int.value) print "Actual ctypes type:", type(my_unsigned_int)