Optimize Python functions by passing direct callbacks into Matlab