Last active
December 17, 2015 15:59
-
-
Save gdementen/5635324 to your computer and use it in GitHub Desktop.
recursive ctypes structures make numba fail to compile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
if numba.utils.hashable(ctypes_type) and ctypes_type in ctypes_map: | |
RuntimeError: maximum recursion depth exceeded |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ctypes import pythonapi, Structure, POINTER | |
from numba import autojit | |
class PyInterpreterState(Structure): | |
pass | |
class PyThreadState(Structure): | |
pass | |
PyThreadState._fields_ = [ | |
("next", POINTER(PyThreadState)), | |
("interp", POINTER(PyInterpreterState)) | |
# ... | |
] | |
savethread = pythonapi.PyEval_SaveThread | |
savethread.argtypes = [] | |
savethread.restype = POINTER(PyThreadState) | |
restorethread = pythonapi.PyEval_RestoreThread | |
restorethread.argtypes = [POINTER(PyThreadState)] | |
restorethread.restype = None | |
@autojit | |
def test_gil(): | |
threadstate = savethread() | |
restorethread(threadstate) | |
test_gil() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment