start to move the logic about which optimisations to use into python