Earlier quoted context omitted.
I believe this feature was introduced in Python 3.6. This implementation may be 3.6 Edit: Just checked the site and see it uses PyPy which states -- on their site -- the python version is 3.5.3
I can't do: a, *b = range(3) which should be 3.5 i think.
PyPy.js: Python in the web browser
91–100 of 129 posts
Re: PyPy.js: Python in the web browser
#92Would it be sane to use this to run Python modules in node.js?
For all other cases, stay in Node or use a lib from a language more suited to WASM compilation. Now, if it's an option between this and a native Node module, that depends on your opinion of Node FFI and native Node modules.
Re: PyPy.js: Python in the web browser
#93 >>> os.getlogin()
'root'
Nice joke :)Re: PyPy.js: Python in the web browser
#94The 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…
Here's the code:
import time
a=-1
j = 0
i=0
while j Re: PyPy.js: Python in the web browser
#95The 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…
Though trying to add the numbers for 1 to a million in a loop javascript was about 10 - 20 times faster when I tried it.
Besides, if calculations are important, you would use numpy.
Re: PyPy.js: Python in the web browser
#96The 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…
Which version of python 3 did you test with? I expected 3.6+ to be faster than python 2.7
Re: PyPy.js: Python in the web browser
#97The 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…
Which version of python 3 did you test with? I expected 3.6+ to be faster than python 2.7
Re: PyPy.js: Python in the web browser
#98The 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…
I wonder if the time.time is the slow part there? Maybe worth doing a busy look for say 5 million iterations, timing that then doing the calculation for loops per second.
But you made me think: indeed, the underlying call could be slower from JS whereas from pypy/python{2,3} it's fast (or vice versa). So I just tested a version where it checks how long ten million iterations take (n=3). Code here: https://hastebin.com/uyuhecabek.py
browser/pypy 5.25 seconds
python 3.6.6 2.16 seconds
python 3.7.0 2.08 seconds
python 2.7.15 1.42 seconds
pypy 6.0.0 0.01 seconds
Since there is no syscall to be made, pypy can do this in compiled code and is blazingly fast (I bet C/assembly isn't much faster there), and the rest seems comparable to the previous estimate: the browser version is 2.25× slower compared to python3 (now 2.43×) and 3.33× slower compared to python2 (now 3.70×).Re: PyPy.js: Python in the web browser
#99https://github.com/replit-archive/empythoned
I deployed this at scale at Codecademy were millions of users were using it to learn Python but hit a lot of problems with it. For one, if you're in a 3rd world country then the bundle size is a non-starter (this is potentially solved with WASM being a binary format). Even if you managed to download the bundle lots of old computers would run out of memory trying to parse the JS (again probably solved by the binary AST format of WASM). Because of this and a few other issues (the dev experience of emscripten was really hard) we had to move away to running code on remote containers.
Now that I'm back working on Repl.it full time I'm excited to play again with the tech and see what we can do with it this time around.
Re: PyPy.js: Python in the web browser
#100The 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…
Though trying to add the numbers for 1 to a million in a loop javascript was about 10 - 20 times faster when I tried it.