It would be good to use some of python's capabilities for improving runtime speeds, such as [cython](http://cython.org/) or [theano](http://deeplearning.net/software/theano/).