It is better to make cdef block nogil like: cdef extern from "<complex>" namespace "std" nogil: and let methods without nogil