TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

PythonJS now faster than CPython

138 pointsby tyrionalmost 11 years ago

16 comments

chubotalmost 11 years ago
Can it run real programs (i.e. not benchmarks)?<p>If so I will be impressed. Glancing over the code, it looks pretty short, and I can imagine benchmarks will run, but not real programs.<p><a href="https://github.com/PythonJS/PythonJS/blob/master/pythonjs/pythonjs.py" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;PythonJS&#x2F;PythonJS&#x2F;blob&#x2F;master&#x2F;pythonjs&#x2F;py...</a><p>It&#x27;s true that most programs don&#x27;t use all the dynamism of Python, but they probably depend on something that does (e.g. Django). Python is more dynamic than JavaScript, in that it has __getattr__, __setattr__, __getitem__, etc.<p>If not, it&#x27;s not fair to compare it to PyPy... PyPy actually runs arbitrary Python programs.
评论 #7865802 未加载
评论 #7865750 未加载
评论 #7866381 未加载
JeremyBanksalmost 11 years ago
I also wrote an interpreter, and it&#x27;s 500x faster than CPython or PyPy.<p>(As it happens, my interpreter can only run a single fixed program, but I&#x27;m not worried: most people won&#x27;t read past the headline when I announce it.)
评论 #7865971 未加载
评论 #7865767 未加载
chuckupalmost 11 years ago
The other interesting and recent &quot;Python in the browser&quot; project is RapydScript - <a href="https://github.com/atsepkov/RapydScript" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;atsepkov&#x2F;RapydScript</a><p>Unlike PythonJS, it does not have the goal of being 100% Python compatible, but instead takes the CoffeeScript approach. So, like Coffeescript, you get (mostly) clean Javascript output, no huge library dependency, runs nearly as fast as Javascript, etc.<p>Check out the &quot;ants&quot; demo - <a href="http://salvatore.pythonanywhere.com/RapydBox/default/editor" rel="nofollow">http:&#x2F;&#x2F;salvatore.pythonanywhere.com&#x2F;RapydBox&#x2F;default&#x2F;editor</a><p>I&#x27;ve been playing around with both PythonJS and Rapydscript, and I like both. Different goals. PythonJS can output to Lua, too - so there&#x27;s the whole Python in LuaJIT angle which could be very interesting as it matures.
评论 #7867196 未加载
WizKidalmost 11 years ago
According to the footnote he tested with pypy 1.9. There was just a post here a day or two ago that pypy 2.3.1 was release. Seems like one should at least use the latest version when testing. Pypy 1.9 was release 2 years ago.
评论 #7865771 未加载
rchalmost 11 years ago
This just translates Python syntax into JavaScript, assuming a direct translation is possible.<p>Neat, but a more compelling post would compare with CoffeeScript and check build times, high-level syntax, and features like generators, list comprehensions, itertools, functools, and so on.<p>Edit: why the downvote? Am I incorrect about something? If so, I&#x27;m genuinely curious to know what I&#x27;m overlooking here.<p>Edit 2: I went over to the github page and it is in fact a &#x27;transpiler&#x27;, though it can run self-hosted in node, and the features list includes both list comprehensions and yield (i.e. generator functions). It looks like the itertools and functools libraries aren&#x27;t supported yet, but doing so really wouldn&#x27;t be too difficult. CoffeeScript is a direct output option too.
评论 #7866680 未加载
millstonealmost 11 years ago
Python has bignums by default. I was curious how PythonJS implemented bignums, so I tried it, and the answer is: it doesn&#x27;t. It just uses ordinary JavaScript doubles.<p>This is a critical difference that ought to be called out, especially in the &quot;add&quot; micro-benchmark, which is measuring two very different things in the two implementations.
评论 #7866836 未加载
vomitcuddlealmost 11 years ago
If this project gains more traction, maybe it will get more people interested in Dart. (which is essentially javascript with a standard library reimagined for the things people are using javascript for today: async APIs, stream processing, mapreduce, webapps, etc.)
评论 #7866415 未加载
评论 #7865757 未加载
spullaraalmost 11 years ago
Near as I can tell, because CPythong is so tied to native code at every turn, none of the other VMs have any real chance of success without bridging to them.
评论 #7868442 未加载
评论 #7866205 未加载
评论 #7867560 未加载
zorboalmost 11 years ago
Ah yes, the old X is faster than Y pointless nonsense. Let&#x27;s ask the basic questions that always come to mind:<p>- Does X do all or at least most that Y does?<p>- Are the benchmarks sane? I.e. not the pointless arithmetic fibonacci that nobody really uses, but the useful stuff such as regexps etc.
pfrazealmost 11 years ago
Python in the browser would be pretty fun. Congrats on the speed improvements.
anilshanbhagalmost 11 years ago
PyPy uses JIT to generate optimized code during runtime. As many comments noted, PythonJS may not support all Python features but still don&#x27;t understand why PyPy performing worse than PythonJS.
评论 #7867201 未加载
评论 #7867563 未加载
SnowLprdalmost 11 years ago
The comparisons to PyPy would be much more meaningful if they weren&#x27;t based on a version of PyPy that&#x27;s <i>over two years old</i>: PyPy 1.9 was released in 2012.
评论 #7881710 未加载
评论 #7875876 未加载
pandleralmost 11 years ago
I&#x27;d be interested to see how it stacks up against other python-to-js converters in terms of both speed and supported python features.
coherentponyalmost 11 years ago
It&#x27;d be interesting to see a comparison with CPython with the &#x27;numpy&#x27; backend using a vectorised code.
评论 #7888336 未加载
zzleeperalmost 11 years ago
Nitpick: vertical text is really hard to read, sp if the image is compressed like that. Next time please use some bars instead of columns!<p>Asides from that, this looks quite promising!
bayesianhorsealmost 11 years ago
PythonJS might win importance if there was a framework to build webapps with it. Otherwise it&#x27;s only a curiosity...