Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Thoughts about PyScript Performance#2347

MominIqbal-1234 started this conversation inProposals
Discussion options

Huge Appreciation to the PyScript Team 🙌

Thank you to the entire PyScript team for building such an awesome project! It's a major step forward for Python in the browser.


Why JavaScript Feels So Fast in Browsers ⚡

JavaScript is incredibly fast in the browser, likely because it's compiled by highly optimized JavaScript engines like V8 (used in Chromium). These engines are deeply integrated into the browser itself, which gives JS a big performance advantage.


Can Python Catch Up? 🐍🚀

If we can integrate a Python compiler directly into the browser—similar to how JavaScript is integrated—it could become a real competitor to JavaScript. Collaborating with browser projects like Chromium could make this possible.


Final Thought 💡

With continued innovation and support, PyScript could transform how we build and run Python in the browser, opening up new possibilities for developers worldwide.

You must be logged in to vote

Replies: 2 comments 3 replies

Comment options

If we can integrate a Python compiler directly into the browser ...

that's what Pyodide and MicroPython do: they bring the native interpreter toWASM which "compile" at runtime just like Python does.

The claimpyscript is very slow is a bit lame to me:

  • it's bad for search engines results
  • this discussion provides zero evidence around why, where, how it's slow ... there's nothing to work on for this team
  • it's unnecessaryFUD we don't need, specially if you appreciate the project

Most importantly, the plethora of demos out there based on WebGL games to complex data-visualization applications would beg to differ your conclusion but it's true that we know some area could improve, yet it has nothing strictly to do with PyScript:

  • MicroPython starts up in a matter of few milliseconds, that's the equivalent of any React app bootstrap
  • Pyodide takes 1 to N seconds to bootstrap but once it does bootstrap, it's as fast as it can go (and standard CPython, so a bit slower thanMicroPython but fully CPython compliant)

TheWASM target/runtime lackscooperative GC andJIT but this has nothing to do with PyScript and it's not evenPyodide orMicroPython fault so ... what you are suggesting should rather land atWHATWG as it's a request for browsers/vendors, not for this team, we can't decide what browsers ship out there.

As summary, I think we should quickly edit the title of this discussion as it does a bad job at proposing anything concrete or addressable by the PyScript team but I'll wait@ntoll thoughts in case he has a different opinion.

You must be logged in to vote
0 replies
Comment options

Hey hey@MominIqbal-1234 - thank you for the feedback and kind words, it's really appreciated.

So, performance. 😄

That's a difficult nut to crack.

As@WebReflection pointed out, there are lots of complex factors related to the performance of PyScript. It is not enough just to say, "PyScript is very slow"... because I want to reply by asking, "compared to what, and in what dimension of measurement?". 😉 Does it start quickly? That depends on the runtime and (crucially, something over which we don't have control) network latency on first load. Does it evaluate code quickly? The biggest factor is likely the quality of the code PyScript is evaluating - even the world's fastest computer coupled with efficiently compiled code will grind to a halt if the code itself is written to perform asO(2^n) in complexity. And there are other subtle "performance" characteristics that are qualitative rather than quantitative in nature. For instance, the fact that Python makes it easy to write code so the time spent by the developer to make stuff work (something that is financially very expensive) is likely to be less with Python than, say, C++. It's also easy to get obsessed by "performance" as a synonym for "speed" because it's easy to measure, check and test. But fast doesn't necessarily mean better. You might have the fastest platform in the world, but if it's a pain to use, it's not a great trade-off.

So, as always, the answer to the question of PyScript performance is, "it depends". 👍

My personal view is to ask, "is PyScript's performance, across many different quantitative and qualitative dimensions, good enough?" That these various dimensions interfere with each other means we have to think very carefully about the trade-offs of preferring one type of performance over another. Crucially this means we pay attention in an enlarged and broad minded manner - and NOT just focus on "speed" (again, of what? Startup, execution, interaction with the browser, compilation of bytecode etc..?)

These are important discussions to have, and we welcome your comment, but (if I may), I'll change the title from the rather loaded, "PyScript is slow" to "Thoughts about PyScript Performance", since this is less pejorative and more accurately reflects the subtle, nuanced and very Very VERY difficult task of engaging with the performance characteristics of PyScript. 🤔

So, let the discussion begin..! This is what open-source engineering is all about. We lift each other up. 🚀

You must be logged in to vote
3 replies
@MominIqbal-1234
Comment options

First of all, thank you for changing the title to “PyScript is slow.” It makes much more sense now. I really appreciate all your hard work and effort—I know it’s difficult to maintain project.

My intention wasn’t to criticize the PyScript team. I think my point got misunderstood. I was comparing PyScript to browser JavaScript when I asked:

“If we can integrate a Python compiler directly into the browser—similar to how JavaScript is integrated—it could become a real competitor to JavaScript.” My actual question is: Can we integrate a Python compiler directly into the browser, just like JavaScript?

I’ve been following this project from the very beginning, and as a Python developer, I’m looking for a alternative to JavaScript. I hope this clarifies my question.

Please share your thoughts on this idea. Love you, PyScript team ❤@ntoll@WebReflection

@ntoll
Comment options

@MominIqbal-1234 totally understand.

To answer your specific point about browser integration of Python, I had a very interesting chat with some of the WASM folks working at Carnegie Mellon University while at PyCon last week. They've become very interested in Python performance in the browser and have been looking at approaches to clearly articulate and test. This basically boils down to three things:

  1. Compile a Python interpreter to WASM and run it in the WASM sandbox. The problem here is that the user's code running in the interpreter isn't "seen" by the WASM runtime, since it's only running the interpreter. This is the current approach.
  2. Take the bytecode produced by the Python interpreter and transpile that into WASM bytecode. This has the advantage of the WASM runtime interacting with the user's actual code, and can thus bring to bear all the ways in which it makes code efficient (JITting etc...). This is currently being looked at by the folks at CMU, and it's early days.
  3. Entirely remove the Python interpreter from the process and compile the user's code directly to WASM. This has yet to be figured out, yet is similar to the approach our Anaconda colleague@antocuni is taking with his SPy project.

So, there are various routes forward... and these are but one aspect of PyScript "performance" (see my earlier comment). It's also worth pointing out that the timeline for this research and development is likely to be years. So patience, collaboration and learning from each other is key.

I hope this is of interest!

@WebReflection
Comment options

what Nicholas already said ... plus:

If we can integrate a Python compiler directly into the browser ...

I think that is a long line of developers wanting other PLs in the browser, namelyGo,Dart or any other scripting that is more modern and faster thanJS ... but if you think evenDart, a Google project, with Google interest, didn't get a chance to land natively asJS alternative on the Web, I am afraid this quest won't end up well ...however the reasonWASM exist and it's constantly improving is exactly this: allow anyPL to take over ... thePL with the smallestWASM runtime able to produce the best performance will win this race, imho, but we're yet to witness that in practice and it might, indeed, take years, like Nicholas already mentioned.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
None yet
3 participants
@MominIqbal-1234@ntoll@WebReflection

[8]ページ先頭

©2009-2025 Movatter.jp