You could rename the Cython file to sparsefuncs_fast.pyx and move this function to a pure Python file named sparsefuncs.py. You'll also need to import Cython functions in the pure Python file.