def delta_t():
 ts = time()
 while True:
  t = time()
  (dt, ts) = ((t - ts), t)
  (yield dt)

def delta_t ( ) : ts = time ( ) while True : t = time ( ) ( dt , ts ) = ( ( t - ts ) , t ) ( yield dt )
return time between each call like so: tick = delta_t() def get_dt(): return next print get_dt() sleep(1) print get_dt() .