Some python optimisation.