View Single Post
Old 06-06-2011, 05:23 PM   #9
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by kovidgoyal View Post
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?
chaley is offline   Reply With Quote