5 ms·
Seems super interesting, but I'm afraid at how much of a performance impact this might have. Any benchmarks on that? I can't imagine interpreting Python in JS t
by montenegrohugo 6y ago
Seems super interesting, but I'm afraid at how much of a performance impact this might have. Any benchmarks on that? I can't imagine interpreting Python in JS to be cheap.
EDIT: nevermind, they do make a comparison here: https://brython.info/speed_results.html https://brython.info/speed_results.html
There is a hit, but it doesn't seem too outrageous. Might be usable in simple webpages for people coming from Python that don't wish to learn an entire new language.
- factorialboy 6y agoI assume there's CLI for compilation step?
- tgv 6y agoNo, it seems to interpret the text/python script tag.
- goffi 6y agoAFAIK (Brython devs can correct if necessary) it's transpiled live and stored in indexedDB, so after first run it's already transpiler. You can also transpile using CLI to have directly JS. edit: it's indexedDB, not localStorage
- nicoburns 6y agoIt claims that: "Speed of execution is similar to CPython for most operations." Unfortunately CPython is several times slower (roughly 7x?) than most JavaScript engines to begin with. So I imagine it is quite slow.
- wesammikhail 6y agoQuestion: What operations are being done on the client side that requires that much speed? Why is speed even a concern in this case? With modern hardware and the type of applications I am familiar with (rendering tens of thousands of financial data points), I could 50x lower the speed of execution and the client wouldnt even feel it. So I´m geniunly curious what people are working on that requires that much speed/performance?
- tcbasche 6y agoCuriously, I would say that if a frontend technology is fast then that's already improved the user-experience. If your user can click around quickly and if making a mistake isn't a huge setback in terms of time to navigate through loading screens etc. It also gives developers a good starting point - no need to optimise if the language is just natively snappy. But, as is usually the case, your mileage may vary depending on your use case!
- cellularmitosis 6y ago> I could 50x lower the speed of execution and the client wouldnt even feel it Is that a typo? Did you mean "50%"?
- wesammikhail 6y agono 50x. If you design your applications correctly with the right data structures, you rarely need all the computational power today´s machines have. In some cases, yea probably. but in most cases, hardware is already too good!
- CryZe 6y agoWell it seems like the clock example they have can't even hit 60 FPS without consuming 100% cpu (of one core). So yeah you probably don't want to actually use Python in the browser (via a JS interpreter).
- chownie 6y agoI'm getting 2.7% CPU usage with the clock loaded on Firefox, possibly platform dependant?
- tgv 6y agoI've just finished rewriting a standalone python application into a JS browser application, and runtime went from 20 minutes to 1.5s. The most important factor is that the original programmer didn't know what convolution is and that it's a linear operation, but in those 1.5s, V8 manages to run thousands of times through a 250k pixel array, convolve it, and draw it; changing the color mapping takes a mere 4ms, so it can be done with responsive controls. Python just can't do that. Edit: this thing transpiles to JS, apparently, so it might perform.
- ironmagma 6y agoIf I recall, Brython doesn’t behave exactly like CPython but more as a thin Python-like wrapper around JS. There’s not as much emulation as a result and the performance is more on par with JS than something like Skulpt.
- pansa2 6y ago> I can't imagine interpreting Python in JS to be cheap. It doesn’t look like Brython is an interpreter - it’s a Python-to-JavaScript translator.
- Kwantuum 6y ago> people coming from Python that don't wish to learn an entire new language I see this argument all the time but I just don't get it. Python and Javascript are remarkably similar, they have different syntax and the metaprogramming side of things is quite different but aside from that, it's really not a big jump.
- thejohnconway 6y agoSyntax makes a big difference! I am more familiar with Javascript, and while can program Python, I find myself looking up Python’s syntax for things frequently while writing it. It a frustrating experience. I, for one would prefer to just use Python, but Javascript is a necessity for web programming, obviously.
- CryZe 6y agoIt seems like it's about 40 times slower than JS or so, if not more.
- wutbrodo 6y ago> Might be usable in simple webpages for people coming from Python that don't wish to learn an entire new language. I'm reasonably competent in Javascript and I'd definitely rather use something like this for fairly simple projects.