PyScript + micropython runtime

273 views
Skip to first unread message

Kiko

unread,
Nov 13, 2022, 2:55:35 PM11/13/22
to brython
Hi all,

ICYMI, the pyscript folks have been playing with a micropython runtime:
https://pyscript.net/tech-preview/micropython/about.html

Today I've checked the actual sizes of:
- brython.min.js (869 kb)
- brython.min.js + brython_stdlib.js (869 kb + 4.55 Mb)
- PyScript.js + micropython.js + micropython.wasm (48 + 411 + 563 kb) (*)
(*) micropython includes some of the std libs
(http://docs.micropython.org/en/latest/library/index.html).

The other actual option is pyodide (CPython in wasm). It is > 10Mb but
you can access stuff like numpy, scipy, matplotlib, pandas,
scikit-learn (+ tens to hundreds of Mb).

ATM, micropython is implementing a python 3.4 version with some
additions from newer versions but I see it as a very interesting
option once the pyscript folks add some time/money on it and add a
DOM/HTML layer for micropython.
Also, the pyodide folks are working on size reduction and it is a full
CPython implementation with updated versions.

I have not tested performance as this is tricky and it will depend on
what you want to do. To me brython is fast enough for what I would use
it.

What do you think of this new contender?

KR,

Joao S. O. Bueno

unread,
Nov 13, 2022, 10:57:27 PM11/13/22
to bry...@googlegroups.com
The key thing really is HTML/DOM integration. 
Any "Python on the Browser^ solution that does not handle that
in a Python way is but a toy. One can use it to create strange applets,
but there is no real use for that besides "client side Python notebooks".

Brython is still the only  "contender" to do real-world Web frontend, and if
it would only get critical mass, it could overtake for real the mess that the
javascript ecosystem has become.


Kiko

unread,
Nov 14, 2022, 2:27:39 AM11/14/22
to bry...@googlegroups.com
With pyodide you can do so:
https://pyodide.org/en/stable/usage/quickstart.html#accessing-javascript-scope-from-python

I dunno if you mean things like "body <= my_div", etc

>
> --
> You received this message because you are subscribed to the Google Groups
> "brython" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to brython+u...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/brython/CAH0mxTQ1qw6Cdpzjv2SMJtUUURa0MeU3%2BgGMH6oJ9yy%3DkMcJPQ%40mail.gmail.com.
>

Edward Elliott

unread,
Nov 14, 2022, 6:58:45 AM11/14/22
to bry...@googlegroups.com
I've played with similar projects that compile python (or python-like code) to javascript.  Things like pscript, pyjs, skulpt, and others.  They all have similar issues from what I've seen:
  • DOM is available via the default js interface.
  • Most work is done with js libs.  Little if any of python stdlib is available.
  • Interactions between python and js are clunky.  Invariably you run into type conversion issues, signature mismatches, and weird syntax errors in transpiled code.
  • Only a subset of python language is available, and some features don't work as in python.  Not just advanced features like generators, but simple things like list comprehension or indexing.
  • Documentation is usually sparse and incomplete.
The only benefits I've seen are execution / load speed and memory usage.  But it comes at significant cost.  Brython is far more advanced in providing a truly python environment, both in language and standard libs (and documentation!).  Brython is a much better general purpose environment unless speed or memory are major issues.

Pyodide seems the most promising future challenger.  WebASM could be a really solid base for a python implementation.  But WASM is still quite new and untested, there are many maturity issues to sort out.  And pyodide has been more focused on number crunching than a general purpose python environment.

IMO it's rather troubling that a google search for 'python and javascript' or 'python in the browser' returns a dozen results for pyscript before the first result for brython.  Even skulpt, which doesn't seem to have any activity in several years, is higher in the rankings.  It does not bode well that such a new project sucks up so much attention.

However that's not nearly as troubling as browser makers spending 20 years making javascript the only supported platform for client-side development.  Such a terrible awful no good very bad language.  To think of the man hours wasted debugging implicit string / int conversions and name scoping nonsense, all because someone's weekend dorm-room frankenstein language got transmuted into a multibillion dollar global web platform, and no one in the chain ever stopped to say "gee maybe this isn't such a good idea", really makes me weep for humanity.

/rant off


Kiko

unread,
Nov 14, 2022, 8:03:38 AM11/14/22
to bry...@googlegroups.com
2022-11-14 12:58 GMT+01:00, Edward Elliott <ese...@gmail.com>:
> I've played with similar projects that compile python (or python-like code)
> to javascript. Things like pscript
> <https://pscript.readthedocs.io/en/latest/intro.html>, pyjs, skulpt, and
> others. They all have similar issues from what I've seen:
>
> - DOM is available via the default js interface.
> - Most work is done with js libs. Little if any of python stdlib is
> available.
> - Interactions between python and js are clunky. Invariably you
> run into type conversion issues, signature mismatches, and weird syntax
> errors in transpiled code.
> - Only a subset of python language is available, and some features don't
> work as in python. Not just advanced features like generators, but
> simple
> things like list comprehension or indexing.
> - Documentation is usually sparse and incomplete.
>
> The only benefits I've seen are execution / load speed and memory usage.
> But it comes at significant cost. Brython is far more advanced in
> providing a truly python environment, both in language and standard libs
> (and documentation!). Brython is a much better general purpose environment
> unless speed or memory are major issues.
>
> Pyodide seems the most promising future challenger. WebASM could be a
> really solid base for a python implementation. But WASM is still quite new
> and untested, there are many maturity issues to sort out. And pyodide has
> been more focused on number crunching than a general purpose python
> environment.
>
> IMO it's rather troubling that a google search for 'python and javascript'
> or 'python in the browser' returns a dozen results for pyscript before the
> first result for brython. Even skulpt <https://skulpt.org/>, which doesn't
> seem to have any activity in several years, is higher in the rankings. It
> does not bode well that such a new project sucks up so much attention.
>
> However that's not nearly as troubling as browser makers spending 20 years
> making javascript the only supported platform for client-side development.
> Such a terrible awful no good very bad language. To think of the man hours
> wasted debugging implicit string / int conversions and name scoping
> nonsense, all because someone's weekend dorm-room frankenstein language got
> transmuted into a multibillion dollar global web platform, and no one in
> the chain ever stopped to say "gee maybe this isn't such a good idea",
> really makes me weep for humanity.

Tragedy of the commons, free (for them) computation and energy for the
multibillion dollar industry.
>> https://groups.google.com/d/msgid/brython/CAB-sx63xWukQyfZkOk6qoq5J%3DdTemN86wmD5eb7_VTNU1XzfEA%40mail.gmail.com
>> .
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "brython" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to brython+u...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/brython/CAF1%3DpD%3DpGJV2rnf-iPi4qXcg8O8bYPAL8%2Bda1uEgNLiqPT4RJQ%40mail.gmail.com.
>
Reply all
Reply to author
Forward
0 new messages