3 ms·
I agree with everything you said there. I will also point out that there is some fairly low hanging fruit in this PyScript project, if they will attempt to be
by coder543 4y ago
I agree with everything you said there.
I will also point out that there is some fairly low hanging fruit in this PyScript project, if they will attempt to be more "web native". Take this example: https://pyscript.net/examples/panel_kmeans.html https://pyscript.net/examples/panel_kmeans.html
It loads a bunch of large `.whl` files, and they're served up without any apparent compression, which raised my eyebrows immediately. Upon closer inspection, this is a zip file under the hood, so they probably figured that compressing a zip file over the wire was a waste of resources, and they're not really wrong... but, does it need to be a zip file? That means they're shipping a library to handle decompressing and manipulating zip files.
If we unpack the zip file and make an uncompressed tarball out of it, we can feed that through brotli and get a much smaller file:
18M bokeh.whl
9M bokeh.tar.br
The network transfer is now twice as fast, and the browser will do a phenomenal job at decompressing this resource before handing it to the application. The browser will (presumably?) decompress these resources in parallel instead of the (likely) sequential process currently being used, the browser should be faster at decompression anyways, and not handling decompression means less code that PyScript has to ship. Even better, subsequent page loads wouldn't have to keep decompressing the same bundle over and over... it'll just be a cached resource. You'd still need to handle the tar format, but that shouldn't be too terrible.
Basically all browsers support Brotli[0], and you could always have a slow fallback for the... checks notes... IE 11 users out there.
This kind of low hanging fruit won't magically fix all the problems with PyScript, but it could go some distance towards making it more palatable for the purpose of bundling up a lightly modified Python application for use over the web.
[0]: https://caniuse.com/brotli https://caniuse.com/brotli