News for hackers. Stuff that matters.
Re:Python Is Not C by maxerickson on Thursday July 02, 2015 @12:28PM (#9819947)
You should use the built in pow for the python version (or the double asterisk operator). I guess most of the difference with PHP is there.

The type conversion behavior of the math.pow function is clearly documented:

https://docs.python.org/3/library/math.html#math.pow

Re:Python Is Not C by bite_victim on Thursday July 02, 2015 @12:49PM (#9820064)
I have updated the test with the new figures that I got. Initially I only tested with Python 2 with math.pow. I have to say I am quite disappointed with the performance of Python 3 though and even using the built-in pow function, PHP 5.6 still is the fastest in this particular case.
Re:Python Is Not C by maxerickson on Thursday July 02, 2015 @12:53PM (#9820092)
The call to int is unnecessary when using the built in.
Re:Python Is Not C by bite_victim on Thursday July 02, 2015 @01:06PM (#9820175)
I am a clumsy individual. Dropping the int call resulted in shaving 3.5 seconds. But how is this possible?! It's ridiculous, really!
Re:Python Is Not C by maxerickson on Thursday July 02, 2015 @01:33PM (#9820337)
The CPython interpreter is pretty naive, so it more or less does what you tell it to.
Re:Python Is Not C by bite_victim on Thursday July 02, 2015 @01:40PM (#9820379)
PHP is no better, if you add an intval call it will add almost 4 seconds to the result! This is an extraordinary proof that being a little sloppy can cost you a lot when using interpreted scripting languages!

Also, I am thinking if and how much speed gain could one inject by not using OOP in PHP...

Re:Python Is Not C by acveilleux on Thursday July 02, 2015 @12:50PM (#9820068)
Indeed on my workstation (Xeon W3565 @ 3.2Ghz, x64 linux, Python 2.7):

    math.pow() version: 11.7s

    pow() version: 6.4s

    ** version: 5.2s