News for hackers. Stuff that matters.
Re:Brython – A Python 3 implementation for client-side web p... by skocznymroczny on Monday July 06, 2020 @06:27AM (#23746371)
Couldn't you just sent the bytecode .pyc instead to fix the no minification issue?
Re:Brython – A Python 3 implementation for client-side web p... by meredydd on Monday July 06, 2020 @06:29AM (#23746381)
This is exactly what BeeWare's Batavia does: compile to bytecode server-side, then run a remarkably small interpreter in the browser. This is a substantial win: parsing is a CPU hog, and Brython's architecture does it every time the page loads.

That said, in order to support `eval` and friends, you still need a full-fat compiler in the browser. So the best route is probably to use a full-service Python->JS compiler, but compile most of the code ahead of time. That's where we're heading with Anvil (we use https://skulpt.org for the client side, but it's the same principle).

My colleague wrote up a pretty wide-ranging comparison of browser-based Python interpreters. It describes how (and why) Brython, Batavia, Skulpt, Transcrypt, and Pyodide differ, and the tradeoffs they're chasing:

https://anvil.works/blog/python-in-the-browser-talk

Re:Brython – A Python 3 implementation for client-side web p... by StavrosK on Monday July 06, 2020 @07:32AM (#23746781)
In twenty years of professional Python development, I've never used eval once. I'm not saying nobody ever needs it, but it's a niche feature that the vast majority of programs can do without, and is probably not worth the tradeoff.
Re:Brython – A Python 3 implementation for client-side web p... by _ZeD_ on Monday July 06, 2020 @08:26AM (#23747140)
have you ever used namedtuple? then you have: https://bugs.python.org/issue3974
Re:Brython – A Python 3 implementation for client-side web p... by duckerude on Monday July 06, 2020 @10:30AM (#23748261)
namedtuple could be implemented without exec/eval, and nowadays, it almost is.

This is the only part left that uses it, to create the constructor: https://github.com/python/cpython/blob/master/Lib/collection...

Even there it's not strictly necessary. You could accomplish the same thing with a variadic function that does its own argument parsing, it'd just be slower and not play as well with reflection. So you could port it to a Python implementation without eval().

Re:Brython – A Python 3 implementation for client-side web p... by danijar on Monday July 06, 2020 @10:24AM (#23748198)
It's necessary if you want to offer an interactive Python shell in the browser, e.g. for websites that teach programming or otherwise use programming as a means of user interaction.
Re:Brython – A Python 3 implementation for client-side web p... by airstrike on Monday July 06, 2020 @11:38AM (#23749042)
Which is like 0.0001% of the web
Re:Brython – A Python 3 implementation for client-side web p... by jononor on Monday July 06, 2020 @08:06AM (#23747013)
You probably have used a Python REPL though? Either on commandline or in iPython shell or similar. This relies on eval type functionality somewhere in the chain.
Re:Brython – A Python 3 implementation for client-side web p... by cellularmitosis on Monday July 06, 2020 @06:42AM (#23746455)
Whitespace isn't the important part of minification. Content-encoding: gzip can handle that.
Re:Brython – A Python 3 implementation for client-side web p... by weego on Monday July 06, 2020 @06:31AM (#23746391)
This is just a python interpreter. pyc is useless here
Re:Brython – A Python 3 implementation for client-side web p... by pletnes on Monday July 06, 2020 @06:41AM (#23746448)
The interpreter interprets bytecode, i.e .pyc