On Tue, 23 Oct 2007 15:34:19 -0000, Josiah Carlson <[EMAIL PROTECTED]> wrote:
> [snip]
>
>Calling time.time() is relatively inexpensive in comparison to pure
>Python function calls, but indeed, it could be a bottleneck.

Did you benchmark this on some system?

There isn't really any "pure Python function calls" that can replace
time.time() in a sensible way, so I made up one that does some random
things (including calling another Python function) and compared it to
time.time:

  [EMAIL PROTECTED]:~$ python -m timeit -s '
  def g():
      return 1. + 2 + 3 * 4 - 5 / 6 + 7 ** 8
  def f():
      return g()
  ' 'f()'
  1000000 loops, best of 3: 1.39 usec per loop
  [EMAIL PROTECTED]:~$ python -m timeit -s 'from time import time as f' 'f()'
  100000 loops, best of 3: 4.68 usec per loop
  [EMAIL PROTECTED]:~$

Not really useful in any real-world sense, but I still wouldn't
characterize time.time as "relatively inexpensive."

Of course, for any real-world work, one would want to profile the
application to determine if removing calls to time.time() could
make a worthwhile difference.

Jean-Paul
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to