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.

CPython's main branch running in the browser with WebAssembly

268 pointsby bobbiechenover 3 years ago

17 comments

ridiculous_fishover 3 years ago
One of the painful aspects of WASM is there&#x27;s no blocking calls. You can&#x27;t say &quot;wait for the next event;&quot; instead you must return to the outermost event loop, and wait to be called back.<p>How does Python-in-WASM work around that? For example, how does `for line in sys.stdin:` work if you can&#x27;t actually block on stdin?<p>Emscripten has some support for this via the &quot;asyncify&quot; transform, which layers additional control flow to enable return all the way up the call stack, and then &quot;rewind&quot; back down into it. But this bloats the code (and is also buggy) so maybe it&#x27;s not being used.
评论 #29377271 未加载
评论 #29377220 未加载
评论 #29377444 未加载
评论 #29377228 未加载
评论 #29377248 未加载
评论 #29377355 未加载
评论 #29378867 未加载
评论 #29381570 未加载
评论 #29383019 未加载
评论 #29376800 未加载
trothamelover 3 years ago
Although it&#x27;s only Python 2.7, cpython-based games have been running in the web browser for years.<p><a href="https:&#x2F;&#x2F;beuc.itch.io&#x2F;the-question-web" rel="nofollow">https:&#x2F;&#x2F;beuc.itch.io&#x2F;the-question-web</a><p>(I&#x27;m the lead developer of Ren&#x27;Py, though Sylvain Beucler did most of the work. He also has a 3.8 port here: <a href="https:&#x2F;&#x2F;www.beuc.net&#x2F;python-emscripten&#x2F;python&#x2F;dir?ci=tip" rel="nofollow">https:&#x2F;&#x2F;www.beuc.net&#x2F;python-emscripten&#x2F;python&#x2F;dir?ci=tip</a> )
评论 #29376650 未加载
评论 #29376582 未加载
评论 #29456252 未加载
评论 #29377281 未加载
mrichover 3 years ago
It&#x27;s a pity WASM and all the tech around it wasn&#x27;t available 20 years ago when Javascript was added to the browser, we&#x27;d all be using python now and node.js wouldn&#x27;t exist at all ;)
评论 #29377656 未加载
评论 #29379699 未加载
评论 #29380674 未加载
评论 #29379272 未加载
评论 #29384347 未加载
eastonover 3 years ago
Guido responded and wondered if this could be integrated into github.dev for Python work in the browser without remote compute. That’s a very cool idea, but I wonder if this would work any better with the usual suspects (pandas, numpy, mathplotlib) than the other attempts like pyodide which make more modifications to CPython.
评论 #29379014 未加载
pettersover 3 years ago
What is the novelty here?<p>E.g. we have <a href="https:&#x2F;&#x2F;github.com&#x2F;pyodide&#x2F;pyodide" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;pyodide&#x2F;pyodide</a> and other examples.<p>The cool part here is Emscripten, which has been around for a long time.
评论 #29376545 未加载
评论 #29377634 未加载
pansa2over 3 years ago
I imagine the biggest downside of this approach is simply the size of the CPython implementation. Does anyone know how big it is when compiled to WASM?<p>I wonder if anyone has tried the same approach using MicroPython.
评论 #29378466 未加载
wheelerof4teover 3 years ago
This is it. This is the beginning of a revolution. Prepare your fork-picks.<p>Jokes aside, JS ecosystem really needs a competitor. Web developers have been cutting corner after corner for decades, with ever increasing disregard for performance and memory consumption.<p>Now with both Python and Rust in the browser, things may change for the better.
评论 #29380244 未加载
评论 #29380618 未加载
评论 #29379416 未加载
brian_hermanover 3 years ago
<a href="https:&#x2F;&#x2F;www.destroyallsoftware.com&#x2F;talks&#x2F;the-birth-and-death-of-javascript" rel="nofollow">https:&#x2F;&#x2F;www.destroyallsoftware.com&#x2F;talks&#x2F;the-birth-and-death...</a> Just a matter of time now.
infocollectorover 3 years ago
This looks exciting. If anyone knows how to, perhaps they can report how much space this uses in the browser? Some benchmarks? Someday soon I hope we can use this for developing code on the browser to aid with web applications.
评论 #29377093 未加载
stevefan1999over 3 years ago
How does that compares to Brython [1]?<p>[1]: <a href="https:&#x2F;&#x2F;brython.info&#x2F;" rel="nofollow">https:&#x2F;&#x2F;brython.info&#x2F;</a>
评论 #29377109 未加载
评论 #29377116 未加载
matiasbover 3 years ago
Very cool, I did some experiments with libxml on a WASI environment a few years ago (<a href="https:&#x2F;&#x2F;github.com&#x2F;matiasinsaurralde&#x2F;wasm-libxml2" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;matiasinsaurralde&#x2F;wasm-libxml2</a>).
qqumutover 3 years ago
This is like reverse cloud system. Don&#x27;t run on cloud, or in your os, run on your browser.
评论 #29378727 未加载
vermilinguaover 3 years ago
How is it directly replacing the JS REPL in the console? I didn’t know that was possible.
评论 #29376455 未加载
tspikeover 3 years ago
Is there DOM access?
评论 #29377079 未加载
评论 #29376722 未加载
999900000999over 3 years ago
Would it be possible to use Python directly in say Chrome, assuming someone pushed a PR for chromium to do this?
评论 #29376671 未加载
评论 #29376499 未加载
评论 #29377080 未加载
评论 #29377186 未加载
questiondevover 3 years ago
web assembly is making leaps. looks great
评论 #29377649 未加载
pyuser583over 3 years ago
That’s nice.