Fix code explosion from long enum in Python 3, Cython 0.24+

This commit is contained in:
Matthew Honnibal 2017-09-16 12:20:04 +02:00
parent 8a829eb98c
commit 11f2a05ede
2 changed files with 11 additions and 2 deletions

View File

@ -1,4 +1,4 @@
cpdef enum symbol_t:
cdef enum symbol_t:
NIL
IS_ALPHA
IS_ASCII

View File

@ -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)