<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jun 14, 2012, at 1:53 PM, James Bergstra wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On Thu, Jun 14, 2012 at 11:01 AM, Nathaniel Smith <<a href="mailto:njs@pobox.com">njs@pobox.com</a>> wrote:<br><br><blockquote type="cite"><blockquote type="cite">Indeed that would be great as sympy already has already excellent math<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">expression rendering.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">An alternative would be to output mathml or something similar that<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">could be understood by the mathjax rendering module of the IPython<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">notebook.<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I'd find it quite useful if it could spit out the derivative as Python<br></blockquote><blockquote type="cite">code that I could check and integrate into my source. I often have a<br></blockquote><blockquote type="cite">particular function that I need to optimize in many different<br></blockquote><blockquote type="cite">situations, but would rather not pull in a whole (complex and perhaps<br></blockquote><blockquote type="cite">fragile) bytecode introspection library just to repeatedly recompute<br></blockquote><blockquote type="cite">the same function on every run...<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">-N<br></blockquote><br>I was hoping to get by with bytecode-> bytecode interface, are there<br>bytecode -> source tools that could help here?<br><br></div></blockquote><div><br></div><div>There have been some attempts in the past.    The most advanced tool I've seen here is by Sean Ross-Ross:    <a href="https://github.com/srossross/meta">https://github.com/srossross/meta</a></div><div><br></div><div>Here's an example:</div><div><br></div><div>import meta</div><div># get some code object (i.e. from compile or from func.func_code --- with no return statement)</div><div>mod2 = meta.decompile(code)</div><div>meta.dump_python_source(mod2)</div><div><br></div><div>-Travis</div><div><br></div><div><br></div><div><br></div><br><blockquote type="cite"><div>Otherwise it might be possible to appeal to the symbolic intermediate<br>representation to produce more legible source.<br><br>With regards to "pulling in a whole bytecode introspection library" I<br>don't really see what you mean. If the issue is that you want some way<br>to verify that the output function is actually computing the right<br>thing, then I hear you - that's an issue. If the issue that autodiff<br>itself is slow, then I'd like to hear more about the application,<br>because in minimization you usually have to call the function many<br>times (hundreds) so the autodiff overhead should be relatively small<br>(I'm not counting Theano's function compilation time here, which still<br>can be significant... but that's a separate concern.)<br><br>- James<br>-- <br><a href="http://www-etud.iro.umontreal.ca/~bergstrj">http://www-etud.iro.umontreal.ca/~bergstrj</a><br>_______________________________________________<br>NumPy-Discussion mailing list<br>NumPy-Discussion@scipy.org<br>http://mail.scipy.org/mailman/listinfo/numpy-discussion<br></div></blockquote></div><br></body></html>