Turn this:
libm = ctypes.CDLL('libm.so') pow = libm.pow pow.restype = ctypes.c_double pow.argtypes = (ctypes.c_double, ctypes, c_double)
into this:
libm = ctypes.CDLL('libm.so') @libm def pow(x : ctypes.c_double, y : ctypes.c_double) -> c_double: pass
Received some good feedback on https://discuss.python.org/t/annotation-based-sugar-for-ctypes/26579 Working on implementation.
I think it's a duplicate of fixed issue #153903. Now (v3.16) something like proposed above is working, modulo different naming. E.g.:
>>> import ctypes >>> import ctypes.util >>> libm = ctypes.CDLL('libm.so.6') >>> @ctypes.util.wrap_dll_function(libm) ... def sin(x: ctypes.c_double) -> ctypes.c_double: ... pass ... >>> sin(1) 0.8414709848078965
Activity
skirpichev commented on Aug 10, 2026
I think it's a duplicate of fixed issue #153903. Now (v3.16) something like proposed above is working, modulo different naming. E.g.: