Greetings!
I've appended a script (levels1.py) that exhibits some disturbing
timing in GtkAdjustment.set_value(). Try:
time python levels1.py
time python levels1.py foo
Let each run for a minute or two before deleting the main window to
amortize start-up costs.
They both create a window with 10 vscales attached to 10 adjustments.
They then proceed to do about 1000 modifications to the adjustments
per second. The difference is the order. The foo-less version does a
hundred set_value()s on one adjusment, then moves on to the next. The
foo-full version goes through each adjusment, setting them all to one
value, then repeats for another value.
The foo-full version is over an order of magnitude faster than the
foo-less version.
I recoded it in C and the difference disappeard. Profiling the script
just points to set_value().
Does anyone have any idea what might be going on?
Thanks!
Eric
#!/usr/local/bin/python
from gtk import *
import os
import sys
w = GtkWindow()
w.connect('delete_event', mainquit)
h = GtkHBox()
w.add(h)
as = []
for i in range(1,11):
a = GtkAdjustment(.5, 0, 1, .01, .1, 0)
v = GtkVScale(a)
as = as + [a]
v.set_digits(2)
h.pack_start(v)
w.show_all()
val = 0
def foo():
global val
for a in as:
a.set_value(val/100.0)
val = (val + 1) % 101
return 1
idx = 0
def bar():
global idx
for val in range(0,101):
as[idx].set_value(val/100.0)
idx = (idx + 1) % 10
return 1
if len(sys.argv) > 1:
timeout_add(10, foo)
else:
timeout_add(100, bar)
mainloop()
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]