Mercurial > pymonkey
view docs/rendered/index.html @ 173:5cfb47c9e916 default tip
Minor line wrap and spacing fixes.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Tue, 01 Sep 2009 03:22:33 -0700 |
parents | dd32a92f6b4f |
children |
line wrap: on
line source
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Pydermonkey Documentation — Pydermonkey v0.0.1 documentation</title> <link rel="stylesheet" href="_static/default.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '', VERSION: '0.0.1', COLLAPSE_MODINDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <link rel="top" title="Pydermonkey v0.0.1 documentation" href="" /> <link rel="next" title="pydermonkey — Access SpiderMonkey from Python" href="pydermonkey.html" /> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="modindex.html" title="Global Module Index" accesskey="M">modules</a> |</li> <li class="right" > <a href="pydermonkey.html" title="pydermonkey — Access SpiderMonkey from Python" accesskey="N">next</a> |</li> <li><a href="">Pydermonkey v0.0.1 documentation</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="pydermonkey-documentation"> <h1>Pydermonkey Documentation<a class="headerlink" href="#pydermonkey-documentation" title="Permalink to this headline">¶</a></h1> <p>Pydermonkey is a Python C extension module to expose the <a class="reference" href="https://developer.mozilla.org/en/SpiderMonkey">Mozilla SpiderMonkey</a> engine to Python.</p> <ul> <li class="toctree-l1"><a class="reference" href="pydermonkey.html"><tt class="docutils literal"><span class="pre">pydermonkey</span></tt> — Access SpiderMonkey from Python</a></li> </ul> <p>Rationale and Goals:</p> <ul> <li><p class="first">Python and JS are fairly complementary languages. Python provides tremendous developer productivity via its dynamic language features, its vibrant library of third-party client-side code, and its ease of readability. JavaScript, on the other hand, is widely known by a vast number of casual programmers due to its availability in web browsers; it was also envisioned from its conception to be executed as untrusted code, which gives it a lot of security features that Python has always lacked.</p> </li> <li><p class="first">There’s an increasing need for being able to run JS on the server side–particularly untrusted JS. For instance, being able to duplicate business logic on the server and client (i.e., browser) would be very useful. Standards-based solutions like <a class="reference" href="https://wiki.mozilla.org/ServerJS">ServerJS</a> are currently paving the way in this field. There’s Java-based solutions like Rhino out there, but nothing really mature is available for the Python world. Ideally, Pydermonkey should enable a Python programmer to create a custom sandboxed environment for executing JS code without needing to write any C.</p> </li> <li><p class="first">Pydermonkey should have awesome Sphinx documentation with doctests and all the trappings of a model Python package. Not only should it be easy for Python programmers to learn how to use the module, but it should also be easy for them to learn more about how SpiderMonkey works by reading the documentation and playing around with the code.</p> </li> <li><p class="first">Pydermonkey needs to have outstanding developer ergonomics. Full cross-language stack tracebacks should be available, for instance, and developers should be able to easily debug. Access to memory profiling facilities in JS-land is a must.</p> </li> <li><p class="first">The module uses the Python C API: no SWIG, Pyrex, or other intermediaries. The obvious disadvantage here is that it means more C code, but the advantages are that</p> <ol class="arabic simple"> <li>contributors don’t need to learn anything other than the Python and SpiderMonkey C APIs to contribute, and</li> <li>it means one less dependency, which makes the build process easier.</li> </ol> <p>The module also doesn’t use ctypes because using the SpiderMonkey C API requires fairly complex preprocessor macros defined in the engine’s header files.</p> </li> <li><p class="first">Finally, Atul has never really made a straight Python CAPI module before, so he wanted to give it a try.</p> </li> </ul> <div class="section" id="building-testing-and-installing"> <h2>Building, Testing, and Installing<a class="headerlink" href="#building-testing-and-installing" title="Permalink to this headline">¶</a></h2> <p>From the root of your pydermonkey repository, run:</p> <div class="highlight-python"><pre>python setup.py build test</pre> </div> <p>This will fetch and compile SpiderMonkey, build the C extension, and run its test suite to ensure that everything works properly.</p> <p>Then run:</p> <div class="highlight-python"><pre>sudo python setup.py install</pre> </div> <p>Note that if you’re on Windows, you won’t need the <tt class="docutils literal"><span class="pre">sudo</span></tt> bit.</p> </div> <div class="section" id="challenges"> <h2>Challenges<a class="headerlink" href="#challenges" title="Permalink to this headline">¶</a></h2> <p>There’s a number of challenges that need to be resolved before pydermonkey can be really usable. Here’s some of them.</p> <p><strong>Garbage Collection</strong></p> <p>Python’s garbage collection uses reference counting, whereas SpiderMonkey’s is mark-and-sweep. It’s possible for there to be situations where there are cycles that exist between SpiderMonkey and Python objects; this is actually quite similar to the relationship between XPCOM and JavaScript in the Mozilla platform–XPCOM uses reference counting too–so detecting such cycles will probably involve creating something akin to <a class="reference" href="https://developer.mozilla.org/en/Interfacing_with_the_XPCOM_cycle_collector">XPCOM’s cycle collector</a>.</p> <p>For the time being, however, such cycles can be manually broken via <a title="pydermonkey.Context.clear_object_private" class="reference" href="pydermonkey.html#pydermonkey.Context.clear_object_private"><tt class="xref docutils literal"><span class="pre">pydermonkey.Context.clear_object_private()</span></tt></a> on valid objects and functions.</p> </div> <div class="section" id="indices-and-tables"> <h2>Indices and Tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h2> <ul class="simple"> <li><a class="reference" href="genindex.html"><em>Index</em></a></li> <li><a class="reference" href="modindex.html"><em>Module Index</em></a></li> <li><a class="reference" href="search.html"><em>Search Page</em></a></li> </ul> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="">Table Of Contents</a></h3> <ul> <li><a class="reference" href="">Pydermonkey Documentation</a><ul> <li><a class="reference" href="#building-testing-and-installing">Building, Testing, and Installing</a></li> <li><a class="reference" href="#challenges">Challenges</a></li> <li><a class="reference" href="#indices-and-tables">Indices and Tables</a></li> </ul> </li> </ul> <h4>Next topic</h4> <p class="topless"><a href="pydermonkey.html" title="next chapter"><tt class="docutils literal"><span class="pre">pydermonkey</span></tt> — Access SpiderMonkey from Python</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="_sources/index.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="search.html" method="get"> <input type="text" name="q" size="18" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="modindex.html" title="Global Module Index" >modules</a> |</li> <li class="right" > <a href="pydermonkey.html" title="pydermonkey — Access SpiderMonkey from Python" >next</a> |</li> <li><a href="">Pydermonkey v0.0.1 documentation</a> »</li> </ul> </div> <div class="footer"> © Copyright 2009, Atul Varma. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.2. </div> </body> </html>