Skip to content

Commit

Permalink
ENH: Release GIL in mecab_dict_index
Browse files Browse the repository at this point in the history
It is relatively safe to release GIL during this process.
  • Loading branch information
sabonerune committed Oct 24, 2024
1 parent a3e2115 commit 9c7a9e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions pyopenjtalk/openjtalk.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ from .openjtalk cimport njd as _njd
from .openjtalk.jpcommon cimport JPCommon, JPCommon_initialize,JPCommon_make_label
from .openjtalk.jpcommon cimport JPCommon_get_label_size, JPCommon_get_label_feature
from .openjtalk.jpcommon cimport JPCommon_refresh, JPCommon_clear
from .openjtalk cimport njd2jpcommon
from .openjtalk.text2mecab cimport text2mecab
from .openjtalk.mecab2njd cimport mecab2njd
from .openjtalk.njd2jpcommon cimport njd2jpcommon
Expand Down Expand Up @@ -282,4 +281,7 @@ def mecab_dict_index(bytes dn_mecab, bytes path, bytes out_path):
"utf-8",
path
]
return _mecab_dict_index(10, argv)
cdef int ret
with nogil:
ret = _mecab_dict_index(10, argv)
return ret
2 changes: 1 addition & 1 deletion pyopenjtalk/openjtalk/mecab.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cdef extern from "mecab.h":
char **Mecab_get_feature(Mecab *m)
cdef int Mecab_refresh(Mecab *m)
cdef int Mecab_clear(Mecab *m)
cdef int mecab_dict_index(int argc, char **argv)
cdef int mecab_dict_index(int argc, char **argv) nogil

cdef extern from "mecab.h" namespace "MeCab":
cdef cppclass Tagger:
Expand Down

0 comments on commit 9c7a9e1

Please sign in to comment.