Re:Brython – A Python 3 implementation for client-side web p...
by tzs on Monday July 06, 2020 @03:15PM
(#23751618)
> White space significant, good luck minifying it
Would it be hard to define an alternate representation of Python code that uses curly braces instead of white space to use over the wire for delivery of front-end Python (with curly braces that occur in the original Python code escaped)?
This code, for example:
def func(foo, bar):
if foo < bar:
foo += bar
return foo * 3
That could then be subject to the usual minimization approaches.
Going back from curly representation to significant white space is easy and fast, although you could probably build your tokenizer so that it never even has to bother. That could make the client side handling of this essentially free.
Re:Brython – A Python 3 implementation for client-side web p...
by dfox on Monday July 06, 2020 @05:36PM
(#23753065)
Both CPython's parser and Python language grammar works in terms of indents/dedents being represented by brace-like tokens, so this is trivially possible transformation.
Would it be hard to define an alternate representation of Python code that uses curly braces instead of white space to use over the wire for delivery of front-end Python (with curly braces that occur in the original Python code escaped)?
This code, for example:
might become on the wire: That could then be subject to the usual minimization approaches.Going back from curly representation to significant white space is easy and fast, although you could probably build your tokenizer so that it never even has to bother. That could make the client side handling of this essentially free.