我想在我的Cython代碼中使用regex.h庫,因爲內置re模塊似乎非常慢,但我在執行它時遇到了很多麻煩。我明白,我要創建一個.pxd文件,並把它作爲我的代碼的外部模塊,但我在Python /用Cython真正的新..在Cython中使用regex.h C庫
這是我regex.pxd文件:
cdef extern from *:
ctypedef char const_char "const char"
cdef extern from "regex.h" nogil:
int regcomp(regex_t* PREG, const char* REGEX, int CFLAGS)
int regexec(const regex_t *PREG, const char *STRING, size_t NMATCH, regmatch_t PMATCH[], int EFLAGS)
我運行命令:$python setup.py build_ext --inplace
而做後,我得到這個錯誤:
regex.pxd:6:27: Expected ')', found '*'
關於如何在我的Cython
代碼中使用regex.h
庫,您有任何其他想法嗎?