Small nit. Could also be: 
    print('Optimizing level %d'%level)