Quote:
Originally Posted by kovidgoyal
The function is only called once if you put it as the test condition for a while loop. Also pass also_queued to has_device_jobs so that you can wait for waiting device jobs as well (I just committed that).
|
If that is true, then python is seriously broken. There is no scenario where the value of a non-inlined function that is used in a loop condition should be cached or optimized away.
To test whether python value caching/loop optimization is broken, I ran:
--
x = lambda y: 0 if y > 10 else y + 1
z = 0
while x(z):
z += 1
print 'here'
---
and got 11 'here's, exactly what is expected.
The GIL shouldn't be an issue because of the sleep.
Is this (incorrect) python behavior documented somewhere?