remove some unnecessary overhead in typed Cython code

By fixing up a couple of static types, Cython can generate much better code here.