Earlier quoted context omitted.
Just playing around: import js c = js.globals.document.createElement("canvas") js.globals.document.body.appendChild(c) ctx = c.getContext("2d") ctx.fillRect(10, 10, 10, 10) Edit: Here is a simple animation: import js import math import time c = js.globals.document.createElement("canvas") js.globals.document.body.appendChild(c) ctx = c.getContext("2d") def render(): ctx.clearRect(0, 0, c.width, c.height) t = time.time…
Sadly, if I paste that in, I get: >>> import js ... c = js.globals.document.createElement("canvas") ... debug: OperationError: debug: operror-type: SyntaxError debug: operror-value: ('EOL while scanning string literal', ('c callback', 1, 12, "r = c.push('import js\n", 0)) debug: OperationError: debug: operror-type: KeyError debug: operror-value: 'r' And then the input window hangs. Strangely enough, if I type it in i…
PyPy.js: A fast, compliant Python implementation for the web
61–70 of 144 posts
Re: PyPy.js: A fast, compliant Python implementation for the web
#62This is glorious. From https://github.com/rfk/pypyjs/blob/master/CONTRIBUTING.rst : > We have the following major components in the PyPy repo: >> An "emscripten" build platform definition, which teaches pypy's rpython toolchain how to compile things with emscripten: ./deps/pypy/rpython/translator/platform/emscripten_platform/. >> An rpython JIT backend that emits asmjs at runtime: ./deps/pypy/rpython/jit/backend/asmj…
Since PyPy compiles RPython to C, couldn't one write a web app in RPython, compile it to C, then to JS (with asm.js) and enjoy a quick page load and smaller file size? By the way, is RPython a nice language to program in?
Not really, if only for the insane compile times. The PyPy authors also heavily discourage using it except for interpreters.
Re: PyPy.js: A fast, compliant Python implementation for the web
#63Earlier quoted context omitted.
Since PyPy compiles RPython to C, couldn't one write a web app in RPython, compile it to C, then to JS (with asm.js) and enjoy a quick page load and smaller file size? By the way, is RPython a nice language to program in?
The differences are described here: https://rpython.readthedocs.org/en/latest/rpython.html
Re: PyPy.js: A fast, compliant Python implementation for the web
#64Please humour my lack of knowledge: is there much difference between something like this and Opal[0]? [0] - http://opalrb.org
Re: PyPy.js: A fast, compliant Python implementation for the web
#65Unfortunately, this is of little use to me. Why? Well, with my Swedish keyboard layout, some alt-combinations are crucial (mainly square brackets, []). And these keypresses do not seem to work.
Re: PyPy.js: A fast, compliant Python implementation for the web
#66Re: PyPy.js: A fast, compliant Python implementation for the web
#67Besides the big download size, it does several things very "right": Full Python data model, access to the full javascript model (albeit slowly currently). Also PyPy is the right choice as the basis for this (as opposed to CPython) because its ecosystem is generally more "pure" Python than CPython's. C Extensions would only get in the way.
it's systematically translating the PyPy interpreter to the Javascript, so it has to get semantics right. However I'm not sure if the drawbacks can be addressed in the current JS model, notably: very slow warmup, huge download size (that's primarily PyPy fault though), the lack of good JS access.
Only for the first time loading it.
It would be great if some big organization (looks at Google) hosts the "standard" version of the file, much like jquery, so that it would be cached and ready to be used on the local machine most of the time.
Re: PyPy.js: A fast, compliant Python implementation for the web
#68If software is eating the world, JavaScript is eating the languages.
Re: PyPy.js: A fast, compliant Python implementation for the web
#69Earlier quoted context omitted.
The differences are described here: https://rpython.readthedocs.org/en/latest/rpython.html
Thanks but to be honest, I'm not proficient in Python, so it's hard to guess if those restrictions would hurt, although they seem fairly small. I was more asking for personnal opinions and projects using it. I wasn't able to quickly find any, it even seems pretty much nobody writes RPython code or maybe people call it Python code so googling is hard.
EDIT: Writing it is more restricted than normal Python, so you have to think about what you do (especially type hints, to make sure it gets what type your variables are) and the long feedback cycles due to compile time are annoying, but still very comfortable. And for building interpreters, the more or less "free" JIT is magic :)
Re: PyPy.js: A fast, compliant Python implementation for the web
#70I watched the presentation in Pycon 2015[1], and I really liked how honest/aware they are about the challenges and tradeoffs (so far, the performance it's pretty bad compared to javascript, and the download size is still an issue). At the end is answered why python can't be directly included in Firefox or other browsers(the presenter/main developer works for Mozilla) [1] https://www.youtube.com/watch?v=PiBfOFqDIAI
Direct link to answer: https://youtu.be/PiBfOFqDIAI?t=1611