On Wed, Aug 8, 2012 at 3:05 PM, Armin Rigo <span dir="ltr">&lt;<a href="mailto:arigo@tunes.org" target="_blank">arigo@tunes.org</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Tim,<br>
<br>
An additional remark: if you&#39;re looking for a tool that is able to<br>
extract a complete call graph from a random Python program, then it&#39;s<br>
impossible.  Only approximations can be done, like e.g. done in<br>
pylint, I believe.<br>
<br>
Such tools are pointless in PyPy but could be useful in other<br>
projects.  For example I can imagine a tool that would statically<br>
compile some version of a random Python program, including all<br>
necessary guards to check at run-time that the assumptions made are<br>
correct.  When these guards fail, it would fall back to a regular<br>
interpreter.<br>
<br>
The difference with PyPy is that the latter uses a tracing JIT<br>
compiler to do at run-time (partially) the same job as I describe<br>
above.  It does it by observation of the run-time behavior, which is a<br>
rather better estimator of the program&#39;s general behavior than a<br>
complex static analysis.  And it dispenses us from writing any such<br>
analysis.  This gives us a result that is not specific to a particular<br>
version of Python (or to Python at all).<br>
<br>
<br>
A bientôt,<br>
<br>
Armin.<br></blockquote><div> </div></div>Hi Armin,<br><br>Thanks for the lengthy reply.<br><br>Fortunately, I don&#39;t need a complete call graph. To get started I really only need procedure level dependency graphs (with control and data-dependencies). This graph is essentially a CFG with extra edges for different types of data dependencies. Thanks to Alex&#39;s previous reply I am taking a look at the CPython bytecode compiler to see if I can extract the local CFG&#39;s it produces.<br>
<br>I could see a static approach potentially beating the dynamic approach prior to the jit getting *hot* but after that it seems like the dynamic approach would win in the long run. Luckily, I don&#39;t have to worry about such things as I have no intention of writing a compiler (well for python anyway you guys seem to have that under control), my main interest lies in studying the evolution of the structure of the programs themselves. <br>
<br>Thanks for the pointers!<br><br>-Tim<br>