Earlier quoted context omitted.
Glorious indeed. At least three levels of abstraction, two JITs, and a host of supporting code. Can we add some more layers like an emulator or get recursive by getting something like Pyasm running inside it?
I work on a machine that has two hypervisors, one third in plan, and more abstraction layers than a lasagna software. It is still very very efficient.
PyPy.js: A fast, compliant Python implementation for the web
111–120 of 144 posts
Re: PyPy.js: A fast, compliant Python implementation for the web
#112Earlier quoted context omitted.
I'm loving this, my head is reeling with the glint of possibilities import js js.globals.console.log('hi!'*5)
Seems to be some issues with the interop still, eg: import js >>> "globals" in dir(js) True >>> "console" in dir(js.globals) False >>> js >>> js.globals.console So apparently introspection doesn't quite work with the wrapped js. Also, if you try: "[ i for i in js.globals]" (or equivalently iterate/loop over the globals-object) - the whole repl/tab hangs. Not really an issue for running business logic in the browser,…
Re: PyPy.js: A fast, compliant Python implementation for the web
#113I 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
Python was one of those languages. You could download an ActivePython distribution and start being able to run python in your web page with a tag.
I'm not sure if this still works in current IE versions. It might.
Re: PyPy.js: A fast, compliant Python implementation for the web
#114Earlier quoted context omitted.
I wonder if Python could be embedded as an addon.
Of course it could. But that would defeat the point, because support wouldn't be widespread enough for any real use (unless you're just using it for an intranet site or something).
Re: PyPy.js: A fast, compliant Python implementation for the web
#115 >>> from datetime import datetime
>>> datetime.now()
Traceback (most recent call last):
File "", line 1, in
File "/lib/pypyjs/lib_pypy/datetime.py", line 1548, in now
return cls.fromtimestamp(t, tz)
File "/lib/pypyjs/lib_pypy/datetime.py", line 1522, in fromtimestamp
result = cls(y, m, d, hh, mm, ss, us, tz)
File "/lib/pypyjs/lib_pypy/datetime.py", line 1459, in __new__
hour, minute, second, microsecond)
File "/lib/pypyjs/lib_pypy/datetime.py", line 312, in _check_time_fields
raise ValueError('microsecond must be in 0..999999', microsecond)
ValueError: ('microsecond must be in 0..999999', 1716000)Re: PyPy.js: A fast, compliant Python implementation for the web
#116Looks like there are some issues to iron out... >>> from datetime import datetime >>> datetime.now() Traceback (most recent call last): File " ", line 1, in File "/lib/pypyjs/lib_pypy/datetime.py", line 1548, in now return cls.fromtimestamp(t, tz) File "/lib/pypyjs/lib_pypy/datetime.py", line 1522, in fromtimestamp result = cls(y, m, d, hh, mm, ss, us, tz) File "/lib/pypyjs/lib_pypy/datetime.py", line 1459, in __new_…
Re: PyPy.js: A fast, compliant Python implementation for the web
#117Re: PyPy.js: A fast, compliant Python implementation for the web
#118Earlier quoted context omitted.
Potentially just one JIT, right? asm.js is AOT compiled on Firefox.
No, because it's "AOT" compiled when it's downloaded or executed (since you have one JIT, you can't AOT compile what it produces). So you can think about it as "just" one JIT, but a very inefficient one
I'm not sure what this means, but if you mean that Firefox doesn't cache compiled asm.js code, that's not true. It does [1].
[1]: https://blog.mozilla.org/luke/2014/01/14/asm-js-aot-compilat...
Re: PyPy.js: A fast, compliant Python implementation for the web
#119Sample code to execute some Javascript code inside PyPy.js. I couldn't find any examples. import js js.eval("console.log(\"hi!\")")
It's a bit messy, but: js.eval('var div = document.createElement("div"); div.style.width = "100px"; div.style.height = "100px"; div.style.background = "red"; div.style.color = "white"; div.innerHTML = "Hello"; document.body.appendChild(div);'); manages to append a div. -- Directly modifying document.body.innerHTML in any way seems to hang it. Both: js.eval('document.body.innerHTML += " ";'); js.globals.document.body.…
import js
jq = js.eval("$")
first_line = jq(jq(".container p")[0])
first_line.text("jQuery was here")Re: PyPy.js: A fast, compliant Python implementation for the web
#120Looks like there are some issues to iron out... >>> from datetime import datetime >>> datetime.now() Traceback (most recent call last): File " ", line 1, in File "/lib/pypyjs/lib_pypy/datetime.py", line 1548, in now return cls.fromtimestamp(t, tz) File "/lib/pypyjs/lib_pypy/datetime.py", line 1522, in fromtimestamp result = cls(y, m, d, hh, mm, ss, us, tz) File "/lib/pypyjs/lib_pypy/datetime.py", line 1459, in __new_…