Ответ 1
Фактически, он уже существует, как часть прозаично названного пакета memory_profiler
:
In [2]: %memit np.zeros(1e7)
maximum of 3: 76.402344 MB per loop
Дополнительная информация на https://github.com/fabianp/memory_profiler#ipython-integration
Изменить: для этого сначала нужно загрузить его в качестве расширения IPython:
%load_ext memory_profiler
Чтобы IPython всегда загружал расширение memory_profiler при запуске, добавьте его в список c.InteractiveShellApp.extensions
в своем профиле ipython_config.py
:
$ grep -C2 c.InteractiveShellApp.extensions ~/.ipython/profile_default/ipython_config.py
# A list of dotted module names of IPython extensions to load.
#
c.InteractiveShellApp.extensions = [
'autoreload',
'memory_profiler',