<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    On 8/25/11 3:45 PM, Raymond Hettinger wrote:
    <blockquote
      cite="mid:98154FC8-AFB3-4CCF-AD06-09CCB4267924@gmail.com"
      type="cite">The <span class="Apple-style-span" style="color:
        rgb(68, 68, 68); font-family: Arial, 'Helvetica Neue',
        sans-serif; font-size: 15px; line-height: 19px;
        background-color: rgb(255, 255, 255); "><a
          moz-do-not-send="true" href="http://t.co/mPKzyp1"
          data-expanded-url="http://gumbyapp.com/"
          title="http://gumbyapp.com/" target="_blank" rel="nofollow"
          class="twitter-timeline-link"
          data-ultimate-url="http://gumbyapp.com/"
          data-display-url="gumbyapp.com" style="margin-top: 0px;
          margin-right: 0px; margin-bottom: 0px; margin-left: 0px;
          padding-top: 0px; padding-right: 0px; padding-bottom: 0px;
          padding-left: 0px; color: rgb(0, 132, 180); text-decoration:
          none; ">http://gumbyapp.com/</a></span><span
        class="Apple-style-span" style="color: rgb(68, 68, 68);
        font-family: Arial, 'Helvetica Neue', sans-serif; font-size:
        15px; line-height: 19px; background-color: rgb(255, 255, 255); "> project
        succeeded in getting Python to run in the browser but it can't
        import pure python modules (because there is no filesystem in
        the browser).</span>
      <div><font class="Apple-style-span" color="#444444" face="Arial,
          'Helvetica Neue', sans-serif"><span class="Apple-style-span"
            style="font-size: 15px; line-height: 19px;"><br>
          </span></font></div>
      <div><font class="Apple-style-span" color="#444444" face="Arial,
          'Helvetica Neue', sans-serif"><span class="Apple-style-span"
            style="font-size: 15px; line-height: 19px;">I think it would
            be wonderful to beef-up this project by bundling-in the rest
            of the standard library.  Gumby was built by compiling
            CPython to LLVM and then generating Javascript.  ISTM it
            would be possible to write a script to transform pure python
            standard library modules into C strings that could also be
            part of the final build.  The import-statement would have to
            be hooked to search for the C string instead of a physical
            file.</span></font></div>
      <div><font class="Apple-style-span" color="#444444" face="Arial,
          'Helvetica Neue', sans-serif"><span class="Apple-style-span"
            style="font-size: 15px; line-height: 19px;"><br>
          </span></font></div>
      <div><font class="Apple-style-span" color="#444444" face="Arial,
          'Helvetica Neue', sans-serif"><span class="Apple-style-span"
            style="font-size: 15px; line-height: 19px;">If that
            technique works, it may not be hard to extend it so that
            user defined python modules could also be incorporated.  If
            so, it would become possible to create standalone Python
            apps that run in the browser.   The process is likely to be
            inefficient, but the gumbyapp site shows that it might be
            good enough for some purposes.</span></font></div>
    </blockquote>
    Mostly as a joke for this past April Fool's day, Matthew Wilkes and
    I cobbled together an import-over-AJAX mechanism [1] for the Python
    interpreter produced by Emscripten [2] (which similarly translates
    LLVM into Javascript).<br>
    <br>
    [1] <a class="moz-txt-link-freetext" href="http://davisagli.com/blog/the-making-of-zodb.ws">http://davisagli.com/blog/the-making-of-zodb.ws</a><br>
    [2] <a class="moz-txt-link-freetext" href="https://github.com/kripken/emscripten/wiki">https://github.com/kripken/emscripten/wiki</a><br>
    <br>
    Our goal was getting ZODB running in the browser, with storage in
    HTML5 localstorage, as demonstrated at <a class="moz-txt-link-freetext" href="http://zodb.ws">http://zodb.ws</a> -- so we
    focused only on the pieces of the stdlib necessary to get that
    running; the emscripten interpreter was missing a lot and we didn't
    have time to learn the emscripten toolchain so we resorted to
    various hacks (e.g. a simple incrementer in place of time.time())
    and borrowing pure-Python implementations from pypy.<br>
    <br>
    David<br>
  </body>
</html>