full name: tenpy.tools.optimization.temporary_level
Context manager to temporarily set the optimization level to a different value.
temporary_level (int | OptimizationFlag | str | None) – The optimization level to be set during the context. None defaults to the current value of the optimization level.
The optimization level to be set during the context.
None | OptimizationFlag
Optimization level to be restored at the end of the context manager.
It is recommended to use this context manager in a
# optimization level default with temporary_level(OptimizationFlag.safe): do_some_stuff() # temporarily have Optimization level `safe` # you can even change the optimization level to something else: set_level(OptimizationFlag.skip_args_check) do_some_really_heavy_stuff() # here we are back to the optimization level as before the ``with ...`` statement