[varLib.iup] Compile with Cython when available

Even with no annotations, makes it ~35% faster.
This commit is contained in:
Behdad Esfahbod 2022-07-28 12:20:27 -06:00
parent 455158f2bf
commit 5d9677038b
2 changed files with 17 additions and 0 deletions

View File

@ -1,3 +1,17 @@
try:
import cython
except ImportError:
# if cython not installed, use mock module with no-op decorators and types
from fontTools.misc import cython
if cython.compiled:
# Yep, I'm compiled.
COMPILED = True
else:
# Just a lowly interpreted script.
COMPILED = False
MAX_LOOKBACK = 8
def iup_segment(coords, rc1, rd1, rc2, rd2):

View File

@ -68,6 +68,9 @@ if with_cython is True or (with_cython is None and has_cython):
ext_modules.append(
Extension("fontTools.cu2qu.cu2qu", ["Lib/fontTools/cu2qu/cu2qu.py"]),
)
ext_modules.append(
Extension("fontTools.varLib.iup", ["Lib/fontTools/varLib/iup.py"]),
)
extras_require = {
# for fontTools.ufoLib: to read/write UFO fonts