Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think you're searching for a python profiler ; </p> <p>you have a bunch of them that you can use , like <a href="http://guppy-pe.sourceforge.net/#Heapy">Heapy</a>, <a href="http://docs.python.org/library/profile.html">profile or cprofile</a> , <a href="http://pysizer.8325.org/">Pysize</a> ...</p> <p><strong>example using Heapy :</strong></p> <p>you have to include this snippet somewhere in your code:</p> <pre><code>from guppy import hpy h = hpy() print h.heap() </code></pre> <p>and it will give you as output:</p> <pre><code>Partition of a set of 132527 objects. Total size = 8301532 bytes. Index Count % Size % Cumulative % Kind (class / dict of class) 0 35144 27 2140412 26 2140412 26 str 1 38397 29 1309020 16 3449432 42 tuple 2 530 0 739856 9 4189288 50 dict (no owner) </code></pre> <p><strong>example with cprofile :</strong></p> <p>you can run it like this:</p> <pre><code>python -m cProfile script.py </code></pre> <p>Output:</p> <pre><code> 5 function calls in 0.000 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 0.000 0.000 &lt;string&gt;:1(&lt;module&gt;) 1 0.000 0.000 0.000 0.000 myscript.py:1(&lt;module&gt;) 1 0.000 0.000 0.000 0.000 {execfile} 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} 1 0.000 0.000 0.000 0.000 {range} </code></pre> <p>You can also use <a href="http://docs.python.org/library/gc.html">gc</a> module to know why python is not freeing your memory, and to ask him to free memory using <a href="http://docs.python.org/library/gc.html#gc.collect">gc.collect()</a>.</p> <p>By the way have you looked at <a href="http://numpy.scipy.org/">numpy</a>, i think it more suitable if you're doing heavy calculation like you said.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload