This is a demonstration of python memory profiling using the package memory_profiler.
(psutil is a recommended optional package for optimizing the profiling).
The demonstration essentially builds a list of tuples in one function and a list of dicts in another.
memory_profiler then gives the memory profile for both functions. It also doubles as a good demonstrator
of why tuples are more memmory efficient than dicts.
- make a virtualenvironment with
virtualenv - install dependencies:
pip install -r requirements.txt - run
python main.py. This will make lists of 10000 items. To increase the number just run:python main.py <new number>e.g.python main.py 100000