[IPython-User] Neat trick: Quick memory usage benchmarking in IPython

klo uo klonuo@gmail....
Sun Jul 1 12:24:07 CDT 2012

On Sat, Jun 30, 2012 at 6:20 PM, Fernando Perez <fperez.net@gmail.com> wrote:
> using the new magics api:
> http://blog.vene.ro/2012/06/30/quick-memory-usage-benchmarking-in-ipython/
> let's test this out, and if it works well we may just ship it.

It looks like it's handy function simplifying memory_profiler usage,
but I won't vote for shipping if my vote counts.

It requires additional module (perhaps popular one and tiny, but
nonetheless), which requires yet additional module - psutil (optional
on Linux but recommended and necessary on Windows).
Introducing two new modules as a new dependency for single handy
function may be seen as too much to otherwise sensitive application as
IPython is toward as minimal requirement as possible, while offering
so much. This is IMHO clear line between IPython and various similar

Also script needs to be corrected for Python3 compatibility.
I understand that I should just copy the script in IPython interpreter
and can test it? If that's correct here is what I got on Ubuntu with
IPython 0.13:

  In [3]: %memit np.ones(1e6)
  best of 3: 0.117188 MB per loop
  Out[3]: 0.1171875

which is different from result author got for some reason, while
profiling it with memory_profiler I get expected result.

On Windows I get this traceback: http://pastebin.com/Mmc7mHQh

Anyhow I'd vote to put this script in IPython wiki, where other
interesting magic functions can be hosted perhaps


More information about the IPython-User mailing list