Page 2 of 2 First 12
  • Jump to page:
    #16
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    394
    Rep Power
    51
    Originally Posted by †Yegg†
    Hmm. Where are you accessing that timeit module from?
    Hm?
    Originally Posted by †Yegg†
    Also, not repr(), try it with ``.
    Ok, you're the boss
    Code:
    $ python -m timeit 'str(5.5)'
    100000 loops, best of 3: 3.26 usec per loop
    $ python -m timeit '`float(5.5)`'
    100000 loops, best of 3: 3.56 usec per loop
  2. #17
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Originally Posted by mawe
    Code:
    $ python -m timeit 'str(5.5)'
    100000 loops, best of 3: 3.12 usec per loop
    $ python -m timeit 'repr(float(5.5))'
    100000 loops, best of 3: 3.66 usec per loop
    Try it ahain without calling the float function and you should get a more favourable result .

    Code:
    modem-3672:~ Mark$ python2.4 -m timeit 'str(5.5)'
    100000 loops, best of 3: 9.16 usec per loop
    modem-3672:~ Mark$ python2.4 -m timeit 'repr(float(5.5))'
    100000 loops, best of 3: 9.26 usec per loop
    modem-3672:~ Mark$ python2.4 -m timeit 'repr(5.5)'
    100000 loops, best of 3: 7.36 usec per loop
    Mark.
    programming language development: www.netytan.com Hula

  4. #18
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    394
    Rep Power
    51
    Yes netytan, I know that repr(5.5) is faster than str() My "benchmark" was just a reply to Yegg's repr(float()) suggestion (he thought it was faster). But once again, try repr() with 1.1
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo