> If one is interested in doing this optimally, it should be better to compile python code to javascript directly.
Well no, this is not possible, because python and javascript have very different semantics, notably regarding numeric types. You would have to enclose every python numeral in an object, and that in itself would already cripple the performance quite a bit. It would probably be less than the emscripten approach, but not by that much of a margin.
I started doing a python to lua compiler, and did hit that wall very fast.
Pyjamas python to javascript compiler is basically a toy regarding compliance to python spec. Every number is treated as a float, which means any numeric python library/function may not work correctly in pyjamas.
That's not the only difference in semantics between python and javascript. Just the most performance expensive.