Your library seems like it could take advantage of Cython for greater speedups (but no increase in mem-efficiency). See https://cython.org/