2017-01-08

Lately Grumpy has received some attention on reddit. YouTube Engineering showed a blog post ( Grumpy ) which apparently proved that grumpy scaled much better then CPython on a Fibonacci benchmark. I felt like repeating this microbenchmark with Python to check their results.

The benchmark results

First, the raw runtimes. Very obviously Python is about 100 times faster on 1, 2, 3 and 4 threads. As I only have a 2 core laptop, checking with many more threads did not make much sense. Go scales worse with the number of threads than Python.

Python vs Grumpy on the Fibonacci Benchmark

And on a logarithmic scale.

Python vs Grumpy on the Fibonacci Benchmark

On every single task, Python is between 110 times and 180 times faster then grumpy.

Python than Grumpy

And how is this achieved? I used the almost identical code for Python and grumpy. On Python, I additionally used the numba library, which adds two lines of extra code. Since this library is not available for grumpy I could not use it. It can be argued, whether it is fair to leverage numba. However, if I were to do some task like calculating Fibonacci numbers I would certainly use it, given how simple it is. Or even better, I'd most likely use the @lru_cache decorator to speed things up.

I'd be happy to see a more realistic benchmark comparing grumpy with Python when it comes to serving websites or similar things.