3 ms·
WASM won't change anything. Python is compiled into bytecode and slowly interpreted. Any optimizations at WASM level won't change the bytecode. For example, the
by codedokode 4y ago
WASM won't change anything. Python is compiled into bytecode and slowly interpreted. Any optimizations at WASM level won't change the bytecode. For example, they won't turn range()-based loop into a loop with a counter.
Also, it is unlikely that compiling to WASM will be more effective than to native code because browser cannot afford spending as much time on optimization as a native compiler. Therefore WASM will always be slower than a native code.
If you want to benefit from amazing optimizations that were done for JS, then it is better to transpile your Python code directly into JS.
- toyg 4y ago> Any optimizations at WASM level won't change the bytecode. No, but the bytecode gets better and more efficient with new releases. The point at which it becomes acceptable depends on the use case, of course. > it is unlikely that compiling to WASM will be more effective than to native code It doesn't have to be more effective, it only has to reach a point where the penalty is worth paying. After all, JS is slower than C, but you accept that as a part of larger trade-offs on manpower, ease of deployment, etc. Once the trade-off becomes acceptable for the use case, absolute benchmarks stop being relevant. > If you want to benefit from amazing optimizations that were done for JS, then it is better to transpile your Python code directly into JS. Why stop there? At that point you might as well use JS, since you get the best speeds and chances are you'll have to deal with it anyway at some point. There are already solutions like that out there, and they are not popular precisely for that reason. The beauty of using WASM is that you'll probably never have to touch JS.
- UncleEntity 4y ago> Also, it is unlikely that compiling to WASM will be more effective than to native code because browser cannot afford spending as much time on optimization as a native compiler. No reason whatever compiles the code to wasm can’t perform all the expensive optimizations and the wasm execution environment just runs it. In fact, I would be very disappointed in a tool that didn’t run optimization passes over the code while it still had the language specific information to inform the optimizer. Then you just pass the multi-megabyte wasm payload over to the browser to render your static content — all’s still good in the webdev world.