4 ms·
That's an interesting way to put it. Python does have a form of prototypical inheritance (given how objects end up being `__dict__`s with behaviour defined thro
by rtpg 5y ago
That's an interesting way to put it. Python does have a form of prototypical inheritance (given how objects end up being `__dict__`s with behaviour defined through `__class__`, though not only that!).
Python descriptors are extremely flexible though, and I _guess_ you could emulate almost all of it through Javascript proxies, but I can't imagine the performance of that being great. Hash tables would also not be re-usable between JS and Python (since Python hash tables allow many more varieties of objects), and Python has a distinction between attributes and keyed access (which JS lacks).
Python exposes much more of the global environment and internals than JS does, and doesn't have some of the requirements JS has put on itself for security reasons. I'm not super sure you could emulate Python blocking style with a JS transformation statically. Blocking Python for something that is only available in a non-blocking JS environment would require effectively wrapping every Python operation (since almost every Python operation can have arbitrary side-effects).
I think there are people who write sort of syntax-y transpilers, but that's not really going to lead you down to nice code re-use.