PyPy.js: A fast, compliant Python implementation for the web
This is glorious. From <a href="https://github.com/rfk/pypyjs/blob/master/CONTRIBUTING.rst" rel="nofollow">https://github.com/rfk/pypyjs/blob/master/CONTRIBUTING.rst</a> :<p>> We have the following major components in the PyPy repo:<p>>> An "emscripten" build platform definition, which teaches pypy's rpython toolchain how to compile things with emscripten: ./deps/pypy/rpython/translator/platform/emscripten_platform/.<p>>> An rpython JIT backend that emits asmjs at runtime: ./deps/pypy/rpython/jit/backend/asmjs/.<p>>> A "js" builtin module for the resulting interperter, to allow interaction with the host javascript environment: ./deps/pypy/pypy/module/js/.<p>>Along with these wrappers to help working with the resulting interpreter:<p>>> A wrapper to load up the compiled VM and expose it via a nice javascript API: ./lib/pypy.js.<p>>> A script for bundling python modules into an indexed format that can be easily loaded into the browser: ./tools/module_bundler.py.<p>In <a href="https://github.com/rfk/pypy/blob/master/rpython/jit/backend/asmjs/assembler.py" rel="nofollow">https://github.com/rfk/pypy/blob/master/rpython/jit/backend/...</a> alone, there are 2887 lines of custom Python code to emit asm.js for function and block JITing.<p>And at 3.26 seconds to initialize from cache on a 4-year-old machine, 5MB gzipped (not too much worse than your average high-quality gif) and only 1.5x slower than CPython... this is actually approaching viable if you needed to run Python business logic in the browser. Which I never thought I would see.