3 ms·
Java and Python are actually doing all of the work to compute their trigonometric functions Not true in the case of CPython. It uses the underlying C imple
by Estragon 17y ago
Java and Python are actually doing all of the work to compute their
trigonometric functions
Not true in the case of CPython. It uses the underlying C implementation. See line 270 onwards.
http://www.google.com/codesearch/p?hl=en#2T6lfGELm_A/trunk/Modules/mathmodule.c http://www.google.com/codesearch/p?hl=en#2T6lfGELm_A/trunk/M...
- jbooth 17y agoInteresting.. well, I'd think the trig functions would be by far the most expensive part of that program. Is Python really that much slower for control structures? That's literally the only other computation there.
- pbiggar 17y agoWell, every instruction in a Python program requires running through the interpreter loop. Then you have to decode, get the opcode arguments, then actually do the operation. For calling C functions from Python, you also have to extract the C types, call the C function, and wrap the result back up. Its not hugely slow, but yeah, it adds up, and its fairly easy to see why it compares poorly to compiled versions.