Skip to content

Instantly share code, notes, and snippets.

@kirtivr
kirtivr / gist:675bb3e7f7a670af63a4c853c02d8202
Created August 31, 2017 17:19
Ctypes callback example
>>> from ctypes.util import find_library
>>> find_library("c")
'/usr/lib/libc.dylib'
>>> libc = CDLL(find_library("c"))
>>> libc
<CDLL '/usr/lib/libc.dylib', handle 118bf9b80 at 10ea3ecd0>
>>> x = c_int * 5
>>> ia = x(1, 9, 4, 11, 7)
>>> qsort = libc.qsort
>>> qsort.restype = None
@kirtivr
kirtivr / gist:bccb3bddd30fbb49b4a5ba25d1c2e942
Created August 31, 2017 17:08
Ctypes specify argtypes
printf.argtypes = [c_char_p, c_int, c_double]
printf("%s %d %f",...) works
printf("%d %d %d",...) does not work.
@kirtivr
kirtivr / keybase.md
Last active April 5, 2017 18:27
keybase.md

Keybase proof

I hereby claim:

  • I am kirtivr on github.
  • I am kirtivr (https://keybase.io/kirtivr) on keybase.
  • I have a public key whose fingerprint is 380A BAF9 1FA4 A7AD 9306 0483 C160 F5EB F929 A13F

To claim this, I am signing this object: