Use with nogil (instead of PY_BEGIN/END_ALLOW_THREADS()). (dm)