4 ms·
I'd be interested in hearing from others, but I wonder what differences there are for optimizing JS vs Python. A few things come to mind: 1. Python has a ton o
by staticassertion 4y ago
I'd be interested in hearing from others, but I wonder what differences there are for optimizing JS vs Python. A few things come to mind:
1. Python has a ton of C code in its libraries/stdlib, JS did not have that for the vast majority of its usage (browser). Optimizing across the FFI boundary seems unlikely to be a reasonable goal and may complicate optimization opportunity. Let's say you want to do some sort of optimization pass to make sure that `str.append` is not getting overridden - how are you going to handle native code?
2. Python is obscenely dynamic. Runtime generation of classes is not uncommon at all - for example, `@dataclass(slots=True)` creates an entirely new class.
You can overwrite methods, functions, there's heavy use of globals in libraries, no such thing as private implementations, hooks into everything, even importing code has side effects so you can't reorder or lazily import automatically, even reordering imports is unsafe in Python.
It seems really hard to optimize Python at all, and I wonder if we could ever reasonably expect to see a "V8-like" runtime, even assuming that there's funding, which I also doubt. Unless you're willing to break the language I just don't see a Python runtime overcoming these issues. Or introduce something like 'strict' where these things aren't possible.
- pjmlp 4y agoIt isn't more dynamic than either Smalltalk or SELF, whose JIT research ended up on the JVM and JavaScript. A a become: b message completely changes all instances of a to b, across the whole image, including code currently being executed.
- lioeters 4y ago> Smalltalk or SELF, whose JIT research ended up on the JVM and JavaScript That makes me curious - would you have a link or hint where I could learn more on this topic?
- pjmlp 4y agoYou can start here, - http://strongtalk.org/ http://strongtalk.org/ - http://merlintec.com/old-self-interest/msg01011.html http://merlintec.com/old-self-interest/msg01011.html - https://www.cs.cornell.edu/courses/cs6120/2019fa/blog/self/ https://www.cs.cornell.edu/courses/cs6120/2019fa/blog/self/
- lioeters 4y agoGood stuff! Much appreciated.