Live data from Hacker News

PyPy.js: Python in the web browser

pypyjs.org

121–129 of 129 posts

Re: PyPy.js: Python in the web browser

#121
post #52

The speed is surprisingly reasonable. Testing with a simple loop, I get about 1.3-1.4 million loops per second in python3, 2 million loops per second in python2, 14.5 million loops in pypy, and 0.61 million loops in the browser. My code basically calls int(time.time()) until its value changes, doing i+=1 for every time it did not change (n=10 for every platform (python2/3/pypy/browser)). My browser is Firefox 61, ful…

Fetching time in the browser isn't accurate because a lot of trackers exploit timing in order to fingerprint users. A lot of browsers now purposefully reduce the precision of the clock. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... https://johnresig.com/blog/accuracy-of-javascript-time/

The whole Meltdown/Spectre thing also contributed greatly to reducing timer precision.

Re: PyPy.js: Python in the web browser

#124
post #3

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

There have been js/asm.js CPython builds demoed since early days of emscripten, and emscripten is the main WebAssembly toolchain, so it's "just worked" since the beginning.

Re: PyPy.js: Python in the web browser

#125
post #10

I tried to do a little something with Emscripten and WebAssembly, but I stopped on the sockets implementation. It relies on WebSockets. I wonder how well we could emulate real sockets using WebRTC to make WebAssembly apps more sophisticated.

Last I looked Emscripten already used WebRTC's data channel to emulate UDP.

Re: PyPy.js: Python in the web browser

#126
post #83

Would it be sane to use this to run Python modules in node.js?

If you have significant amounts of Python code to reuse in another language, I would recommend:

A) Run it as a subprocess

B) Call it over HTTP request/response

C) Use a message broker like AMQP

Re: PyPy.js: Python in the web browser

#127
post #99

It's really awesome to see how far this has come. I believe we at Repl.it were the first to try something like this in production. We emscriptined CPython to JavaScript and contributed quite a bit to the project in the process (including the initial virtual filesystem implementation). https://github.com/replit-archive/empythoned I deployed this at scale at Codecademy were millions of users were using it to learn Pyth…

Thank you for your work at Codecademy -- a place where I learned how to program. I'm working through my 4th year as a developer :)

Re: PyPy.js: Python in the web browser

#128
post #8

Earlier quoted context omitted.

I think we're roughly already there. I think the pivotal moment where Python 2 could've died out rapidly passed and they kept officially supporting it for too long.

As far as I know, permanent EOL for Python 2 is still Jan 1, 2020 ( https://pythonclock.org/ ). Python 3 was first released December of 2008. That's an awfully long tail.

Fascinating. I always thought Python 2.7 support would end July 3, 2020 (exactly 5+5 years from when 2.7 was released), but for some reason they recently decided to go with Jan 1st.

> Specifically, 2.7 will receive bugfix support until January 1, 2020. All 2.7 development work will cease in 2020.

> I've updated the PEP to say 2.7 is completely dead on Jan 1 2020. The final release may not literally be on January 1st, but we certainly don't want to support 2.7 through all of 2020.

https://www.python.org/dev/peps/pep-0373/#maintenance-releas... https://mail.python.org/pipermail/python-dev/2018-March/1523...

Re: PyPy.js: Python in the web browser

#129
post #117

Earlier quoted context omitted.

Fetching time in the browser isn't accurate because a lot of trackers exploit timing in order to fingerprint users. A lot of browsers now purposefully reduce the precision of the clock. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... https://johnresig.com/blog/accuracy-of-javascript-time/

Oh, how convenient. Sometimes I wonder if we shouldn't find a way to be able to run trusted applications instead of making everyone's life difficult all the time, and that's speaking as a security consultant, not even a developer... but yeah I don't see a good way to make that happen.

This reminds me a bit of ActiveX.
Post reply on HN