diff --git a/spacy/symbols.pxd b/spacy/symbols.pxd index 0b713cb21..e981de6ae 100644 --- a/spacy/symbols.pxd +++ b/spacy/symbols.pxd @@ -1,4 +1,4 @@ -cpdef enum symbol_t: +cdef enum symbol_t: NIL IS_ALPHA IS_ASCII diff --git a/spacy/symbols.pyx b/spacy/symbols.pyx index 9f4009579..dd0e38cad 100644 --- a/spacy/symbols.pyx +++ b/spacy/symbols.pyx @@ -1,4 +1,6 @@ # coding: utf8 +#cython: optimize.unpack_method_calls=False + from __future__ import unicode_literals IDS = { @@ -458,4 +460,11 @@ IDS = { "xcomp": xcomp } -NAMES = [it[0] for it in sorted(IDS.items(), key=lambda it: it[1])] +def sort_nums(x): + return x[1] + +NAMES = [it[0] for it in sorted(IDS.items(), key=sort_nums)] +# Unfortunate hack here, to work around problem with long cpdef enum +# (which is generating an enormous amount of C++ in Cython 0.24+) +# We keep the enum cdef, and just make sure the names are available to Python +locals().update(IDS)