Live data from Hacker News

PyPy.js: Python in the web browser

pypyjs.org

31–40 of 129 posts

Re: PyPy.js: Python in the web browser

#31
post #30

this is pretty neat! I was wondering, are there any projects to transpile python to js, but targeting the server side? It would be interesting to port a flask application, for example, to run on node and benefit from the jit, or maybe use express and call flask through its wsgi interface.

Why not just run these in their native environment?

Re: PyPy.js: Python in the web browser

#34
post #9

This is pretty old, and hasn't seen an update in over a year. I never understand why links links this get posted with no discussion to start it off with. Also, wouldn't this be better implemented with WASM?

Maybe something like this? https://github.com/iodide-project/pyodide

CircleCI: Failed :(

Re: PyPy.js: Python in the web browser

#35

I'd love there to be a client-side webapp development system using Python with feature and output parity to JavaScript. If it was a product, I would buy it.

I've been thinking about building this for Tcl. Tcl has been available in the browser in various forms for decades, but one thing that makes Tcl uniquely suited to a web application style development is its threading model. In Tcl, you access a thread by sending messages to it, in which a Tcl interpreter inside its event loop processes. My plan was to have a client-side Tcl program in the browser that automatically instantiates a second thread, but the thread is a remote thread running on the server, so you would be able to access the server just as if it were another thread.

Something like (client-side):

    thread::send $::tcl-web::server -async {
        do stuff
    } placeToStoreResult
    ...
    vwait placeToStoreResult
    do stuff with result $placeToStoreResult

Re: PyPy.js: Python in the web browser

#36
post #3

Will web assembly have any effect on a future web based python interpreter? Is there one in the works?

WASM plans on adding GC, polymorphic inline cache, direct DOM access, etc. That would allow for Python without having to download the whole runtime. Whenever that happens, it might become more mainstream. Similar for other languages.

Re: PyPy.js: Python in the web browser

#37
post #29

Great project. My team used it for a live-coding Python notebook: https://github.com/inkandswitch/livebook#readme To my surprise it was faster than Jupyter / CPython for some tasks (e.g. loading and parsing large CSVs).

Shouldn't be too surprising, given how PyPy is generally faster than CPython by about x7-8 factor: http://speed.pypy.org/ I'd expect a much larger difference in tasks that are pure Python (loading a CSV is done primarily through the csv module, i.e. all the hot loops are in C).

Yes, but PyPy is usually compiled to machine code (and emits machine code), not to JS.

Re: PyPy.js: Python in the web browser

#38
post #30

this is pretty neat! I was wondering, are there any projects to transpile python to js, but targeting the server side? It would be interesting to port a flask application, for example, to run on node and benefit from the jit, or maybe use express and call flask through its wsgi interface.

You're better off running it on the original version of PyPy, which already uses a JIT.

Re: PyPy.js: Python in the web browser

#39
post #29

Earlier quoted context omitted.

Shouldn't be too surprising, given how PyPy is generally faster than CPython by about x7-8 factor: http://speed.pypy.org/ I'd expect a much larger difference in tasks that are pure Python (loading a CSV is done primarily through the csv module, i.e. all the hot loops are in C).

Yes, but PyPy is usually compiled to machine code (and emits machine code), not to JS.

I love Python but js is close to an order of magnitude faster
Post reply on HN