Skip to content

Instantly share code, notes, and snippets.

View gdementen's full-sized avatar

Gaëtan de Menten gdementen

  • Federal Planning Bureau
  • Belgium
View GitHub Profile
@gdementen
gdementen / recursive_ctypes_struct.py
Last active December 17, 2015 15:59
recursive ctypes structures make numba fail to compile
line 91, in from_ctypes_type
return from_ctypes_type(ctypes_type._type_).pointer()
File "c:\soft\Python27-32b\Lib\site-packages\numba\support\ctypes_support.py",
line 97, in from_ctypes_type
for name, field_type in ctypes_type._fields_]
File "c:\soft\Python27-32b\Lib\site-packages\numba\support\ctypes_support.py",
line 91, in from_ctypes_type
return from_ctypes_type(ctypes_type._type_).pointer()
File "c:\soft\Python27-32b\Lib\site-packages\numba\support\ctypes_support.py",
line 88, in from_ctypes_type
@gdementen
gdementen / gil.py
Last active December 17, 2015 15:59
How to release the GIL inside a numba function through ctypes
from ctypes import pythonapi, c_void_p
from numba import autojit
savethread = pythonapi.PyEval_SaveThread
savethread.argtypes = []
savethread.restype = c_void_p
restorethread = pythonapi.PyEval_RestoreThread
restorethread.argtypes = [c_void_p]
restorethread.restype = None