Hacker News new | past | comments | ask | show | jobs | submit login

With no division it is slower (?)

Very interesting. Looks like sin is faster for arguments less than pi/4 (~=0.7853981633974483):

Edit: "Intel's sin/cos implementation sucks golfballs through gardenhoses for arguments outside of [-pi/4,pi/4]": http://stackoverflow.com/questions/523531/fast-transcendent-...

    $ pypy -mtimeit -s'import math; sin=math.sin; a=0.786' '[sin(a) for x in xrange(1000000)]'
    10 loops, best of 3: 395 msec per loop

    $ pypy -mtimeit -s'import math; sin=math.sin; a=0.785' '[sin(a) for x in xrange(1000000)]'
    10 loops, best of 3: 375 msec per loop

    $ python -mtimeit -s'import math; sin=math.sin; a=0.786' '[sin(a) for x in xrange(1000000)]'
    10 loops, best of 3: 177 msec per loop

    $ python -mtimeit -s'import math; sin=math.sin; a=0.785' '[sin(a) for x in xrange(1000000)]'
    10 loops, best of 3: 155 msec per loop



Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: