KanesMethod optimisation

This simply hoists some constants out of loops.

It cuts down the run-time by ~40% when running [the pydy-code-gen benchmark](https://github.com/PythonDynamics/pydy-code-gen/blob/master/pydy_code_gen/tests/models.py#L97).