Python Memory Usage
The Python language has a feature called Generator Expressions
which were
introduced with PEP 289. You can think of them as a better way of doing certain
operations involving lists. This post is more interested in the memory benefits
the feature provides. We will first introduce the memory_profiler
tool which
can be used to measure the memory usage of a python program. We will then
compare two different pieces of code (one with and the other without generator
expressions) which perform the same operation, explaining why one is more
superior than the other. Finally, we will run a few experiments to demonstrate
and prove our assertion.