from dis import dis from timeit import timeit def g(): condition = True while True: if condition: pass else: break condition = False dis(g) # print(timeit(g, number = 100000000))