3 ms·
I highly doubt that the performance difference is a result of not inlining/unrolling sprintf(). The difference is most likely due to the fact that sprintf() is
by haberman 15y ago
I highly doubt that the performance difference is a result of not inlining/unrolling sprintf(). The difference is most likely due to the fact that sprintf() is parsing the format string over and over, whereas PyPy is only parsing it once.
The printf() family of functions is one of the rare parts of the C standard library that is essentially implementing an interpreter. The format string is a program and the library call runs that program with data that is supplied in the other arguments. So in essence this is comparing an interpreter (sprintf) with a JIT compiler (PyPy generating code for a specific format string at runtime).
I agree it's not a very fair comparison: if this C code was performance critical you would call a specialized function for converting an integer to a string, and this would almost certainly beat PyPy.
- cube13 15y ago>I highly doubt that the performance difference is a result of not inlining/unrolling sprintf(). The difference is most likely due to the fact that sprintf() is parsing the format string over and over, whereas PyPy is only parsing it once. And the fact that it only runs twice as long is pretty impressive, actually. Sprintf is doing the parsing 999,999,999 times more than the PyPy interpreter is.
- deleted 15y ago[deleted]