improved speed by not using the list 'result' in cython