In this post I will talk about some tools that can help us solve a painful problem in Python, especially when using PyPy: memory consumption.
Why are we concerned with this in the first place? Why don’t we care only about performance? The answer to these questions is rather complex, but I’ll summarize it.
PyPy is an alternative Python interpreter, that features some great advantages over CPython: speed (through it’s Just in Time compiler), compatibility (it is almost a drop in replacement of CPython) and concurrency (using stackless and greenlets).
One downside of PyPy is that in general it uses more memory than CPython, due to it’s JIT and garbage collector implementation. Nevertheless, in some cases, it is able to use less memory than CPython.
We will see next how you can measure the amount of memory used by your application.