[IPython-user] Memory Measure
Thu Jan 24 18:55:10 CST 2008
Tom Johnson wrote:
> Similar to timeit, does ipython have something similar for memory
> requirements, such as memit? I know that python doesn't offer a way
> to see how much memory an object has (even ignoring the finer details
> of what such a question means), but perhaps ipython could just report
> the difference in system and swap...? Ideally, I'd like to run a
> single command and have ipython report both the time and memory used
> per loop.
That's difficult to do in a cross-platform manner. Pretty much every different
kind of kernel (Windows, Mach, Linux, FreeBSD, Solaris, etc.) has a different
way to expose this information. Implementing some of them will require C code or
ctypes. That's probably something IPython proper will avoid. It would be useful
as a third-party %magic, though.
Also, unless if your code is leaking memory, the memory usage of the Python
process usually won't go down when you are done with the loop. Python does not
always return memory to the OS until the process exits. Consequently,
integrating this with timeit isn't particularly useful. You could measure the
memory increase on the first iteration, though.
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the IPython-user