How many objects does Python allocate during its interpreter lifetime? – Source Rushter.com
It can be very surprising to see how many objects Python interpreter temporarily allocates while executing simple scripts. In fact, Python provides a way to check it.
To do so, we need to compile a standard CPython interpreter with additional debug flags:
./configure CFLAGS='-DCOUNT_ALLOCS' --with-pydebug make -s -j2
Let’s open an empty interactive REPL and check allocation statistics: