TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

RustPython

607 点作者 BerislavLopac超过 1 年前

28 条评论

DanielHB超过 1 年前
&gt; &quot;it can be compiled to WebAssembly in order to run Python in the browser.&quot;<p>I have seen this approach with C-python and NodeJS already and I think it simply not viable, what they are suggesting is compiling the runtime (the same one you use in non-wasm projects) to wasm and then run your python code on top of it.<p>This is a double-whammy of performance degradation, you basically have two JIT-compilation steps happening (once by the wasm runtime to compile the rust-python wasm and again by the rust-python code compiling your python code). And this is on top of normal performance degradation from using a dynamically typed language compared to a statically typed language<p>To make dynamic languages (even JS) viable to run in a wasm runtime, the language must be compiled directly to wasm.<p>Project still looks pretty cool and useful though, there is plenty of python code that could be useful to use in the browser no matter how badly it runs. Just don&#x27;t try to build a web framework on top of this kind of approach.<p>Edit: Let me reframe this a bit, this is what I think, I haven&#x27;t really benchmarked anything and rust python might be doing some tricks I am not aware of.
评论 #39288509 未加载
评论 #39291996 未加载
评论 #39289372 未加载
评论 #39289237 未加载
评论 #39288552 未加载
评论 #39290244 未加载
RantyDave超过 1 年前
Just putting my hand up to say that MicroPython is awesome (and runs on the RP2040). <a href="https:&#x2F;&#x2F;micropython.org" rel="nofollow">https:&#x2F;&#x2F;micropython.org</a>
评论 #39288887 未加载
评论 #39292173 未加载
martijnarts超过 1 年前
I think it&#x27;s really cool that Python has a healthy third-party interpreter community. PyPy, IronPython, Jython, and now RustPython expand Python&#x27;s accessibility. It&#x27;s very cool to see how many people are working on this, and I wonder what kind of problems with CPython this has exposed also.
评论 #39286814 未加载
评论 #39290067 未加载
评论 #39288408 未加载
sakesun超过 1 年前
I thought RustPython is what Ironpython become after being abandoned for a while.
评论 #39289519 未加载
评论 #39294103 未加载
评论 #39312441 未加载
评论 #39292074 未加载
dang超过 1 年前
Related:<p><i>RustPython – A Python-3 (CPython &gt;= 3.11.0) Interpreter written in Rust</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=35056586">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=35056586</a> - March 2023 (136 comments)<p><i>A full Python interpreter written in Rust</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31086317">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31086317</a> - April 2022 (7 comments)<p><i>Python interpreter written in rust reaches 10000 commits</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29094323">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29094323</a> - Nov 2021 (93 comments)<p><i>RustPython: A Python interpreter written in Rust</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=28280790">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=28280790</a> - Aug 2021 (49 comments)<p><i>RustPython – Python Written in Rust</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=27060802">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=27060802</a> - May 2021 (2 comments)<p><i>A Python interpreter rewritten in Rust, that can run pip</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26030269">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26030269</a> - Feb 2021 (48 comments)<p><i>A Python Interpreter Written in Rust</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19064069">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19064069</a> - Feb 2019 (194 comments)
syrusakbary超过 1 年前
Happy to see RustPython making awesome progress!<p>Note: I just realized that they mention wapm in their homepage. We phased out the WAPM CLI in favor of Wasmer (<a href="https:&#x2F;&#x2F;wasmer.io">https:&#x2F;&#x2F;wasmer.io</a>), so you can simply run in your shell:<p><pre><code> wasmer run rustpython </code></pre> Or, if you want to try it using the Wasmer JS SDK:<p><pre><code> import { Wasmer } from &quot;@wasmer&#x2F;sdk&quot;; let rustpython = Wasmer.fromRegistry(&quot;rustpython&quot;); let instance = await rustpython.entrypoint.run({ args: &quot;-c \&quot;print(1)\&quot;&quot; }); let output = await instance.wait(); </code></pre> Will send a PR soon it can be updated!
评论 #39290823 未加载
评论 #39290793 未加载
posix_monad超过 1 年前
I&#x27;m not convinced that projects like this can really have broad application. The value of Python is interfacing to native libraries, but as soon as you use something like PyPy, you lose access to all of that. It&#x27;s the same story with the performance orientated forks of cPython.
评论 #39290863 未加载
评论 #39289462 未加载
qwerty456127超过 1 年前
&gt; Each of these implementations offer some benefits: Jython, for example, compiles Python 2 source code to Java byte code... IronPython is well-integrated with .NET, which means IronPython can use the .NET framework and Python 2 libraries or vice versa.<p>Python 2 is dead and that&#x27;s why Jython and IronPython, who have failed to catch up with Python 3, are dead as well and are not worth mentioning, are they?
gary_0超过 1 年前
Does it allow sandboxing, or is Lua still the only good option for that?<p>There are so many cases where you&#x27;d rather not give extension scripts unlimited access to the OS and file system, you&#x27;d think this option would be more common...
评论 #39286961 未加载
评论 #39287494 未加载
curt15超过 1 年前
How do extensions work with interpreters written other languages? Does the interpreter still expose a C API?
评论 #39287679 未加载
评论 #39289466 未加载
lastmjs超过 1 年前
We&#x27;ve been using RustPython as the Python interpreter for our project Kybra, which is a Python environment for the Internet Computer Protocol (decentralized cloud, where all programs are automatically replicated across 13-40 nodes). Wasm is the runtime environment on ICP.<p>It&#x27;s been working quite well, though lack of C extensions is a problem. We&#x27;re hoping to move to CPython once the wasi and C extension support is there.<p>But the project works, compiles to wasm32-wasi, and can execute on the live ICP network: <a href="https:&#x2F;&#x2F;github.com&#x2F;demergent-labs&#x2F;kybra">https:&#x2F;&#x2F;github.com&#x2F;demergent-labs&#x2F;kybra</a>
评论 #39290839 未加载
评论 #39291789 未加载
ashish01超过 1 年前
I was curious about how slow (or fast) it is compared to cpython. On fibonacci.py rustpython about 11x slower than cpython.<p><pre><code> def fib(n): if n == 0 or n == 1: return 1 return fib(n-1) + fib(n-2) print(fib(35)) time python3 ~&#x2F;code&#x2F;fibs.py 14930352 ________________________________________________________ Executed in 1.18 secs fish external usr time 1.14 secs 180.00 micros 1.14 secs sys time 0.01 secs 616.00 micros 0.01 secs time .&#x2F;target&#x2F;release&#x2F;rustpython ~&#x2F;code&#x2F;fibs.py 14930352 ________________________________________________________ Executed in 13.44 secs fish external usr time 13.32 secs 175.00 micros 13.32 secs sys time 0.02 secs 776.00 micros 0.02 secs</code></pre>
评论 #39295486 未加载
tracker1超过 1 年前
I&#x27;m curious how large the WASM target is.<p>One of the things that turned me off of C#&#x27;s Blazor WASM was the payload size. I&#x27;ve found some of Rust&#x27;s offerings like yew and leptos more interesting.
评论 #39287318 未加载
coldtea超过 1 年前
Last blog entry being from &quot;Dec 1, 2021&quot; doesn&#x27;t make it sound like there&#x27;s much action.
评论 #39287429 未加载
评论 #39287424 未加载
评论 #39287405 未加载
评论 #39291918 未加载
janalsncm超过 1 年前
I’ve been going the other way, adding rust bindings for some performance-critical code, and calling it from Python. It’s worked wonders, speeding things up 20-30x in some places. This also has the benefit of compiling to WASM if I need to, so it’s a breeze to run my code in the browser.
评论 #39293959 未加载
sbt567超过 1 年前
I&#x27;ve been using RustPython for my side project (scripting purpose) and its been amazing ride so far! (albeit with minimal docs which is understandable at this stage). AFAIK, the parser also been used in the awesome ruff project
rrr_oh_man超过 1 年前
For a dum dum like me who only dabbles in programming:<p>What would be a use case for this?
评论 #39287952 未加载
jjtheblunt超过 1 年前
&gt; RustPython is in a development phase and should not be used in production or a fault intolerant setting. Our current build supports only about half of the Python standard library.
_pdp_超过 1 年前
RustyPython is more memorable and has a catchy flair; my $0.02
评论 #39288719 未加载
评论 #39289021 未加载
iAkashPaul超过 1 年前
Wonder how difficult it would be to write something akin to PyO3 but with python syntax for writing rust programs, just like a subset
thurn超过 1 年前
How does their garbage collection work? Especially in Rust it would be cool to see a concurrent collector.
Hamuko超过 1 年前
&gt;<i>RustPython can be embedded into Rust programs to use Python as a scripting language for your application</i><p>How big are my binaries going to be if I embed a whole Python interpreter in it?
评论 #39288400 未加载
amelius超过 1 年前
Cool. Can I use NumPy, SciPy, PyTorch, Shapely, ...?
sebastianconcpt超过 1 年前
How is it about safety then? All the Rust program parts scripted using python are unsafe?
macawfish超过 1 年前
Pretty cool, especially the potential for using python as a scripting language embedded in rust programs. That said, python makes me wince.
评论 #39286865 未加载
评论 #39286896 未加载
评论 #39286849 未加载
评论 #39286861 未加载
评论 #39286916 未加载
评论 #39286945 未加载
Twixes超过 1 年前
That&#x27;s cool, but now for REAL bare-metal performance someone should rewrite Python in an even lower-level language. That&#x27;s right, Python written in C is gonna be hella fast! Oh, wait…
评论 #39287932 未加载
评论 #39287466 未加载
stratigos超过 1 年前
please, just stop with Python already
评论 #39293031 未加载
sylware超过 1 年前
python is already written in plain and simple C, it is sad to make it depends on such complex language which is rust (no less worse than c++).<p>Actually, I would not mind a python interpreter in rv64 assembly (near 0 SDK) instead.