adding nogil to computationally intensive parts