ctypes is an advanced ffi (Foreign Function Interface) package for Python 2.3 and higher. In Python 2.5 it is already included.
ctypes allows to call functions in dlls/shared libraries and has extensive facilities to create, access and manipulate simple and complicated C data types in Python - in other words: wrap libraries in pure Python. It is even possible to implement C callback functions in pure Python.
ctypes works on Mac OS X, Linux, Windows, Windows CE, Solaris, FreeBSD, OpenBSD. It may also run on other systems, provided that libffi supports this platform.
NOTE: Ctypes is licensed and distributed under the terms of the MIT License.
Requirements:
· Python
What's New in This Release: [ read full changelog ]
· _ctypes built on AIX fails with ld ffi error.
· A ctypes Structure cannot contain itself.
· Add .note.GNU-stack to ctypes' sysv.S so that ctypes isn't considered as requiring executable stacks.
· When a tuple was passed to a ctypes function call, Python would crash instead of raising an error.
· ctypes.string_at(buf, 0) and ctypes.wstring_at(buf, 0) returned string up to the first NUL character.
· ctypes.util.find_library works now on BSD systems.
· Ctypes callback functions only support 'fundamental' data types as result type. Raise an error when something else is used.