3 ms·
I don't think it's even more work. (V8 has the dynamic deopt stuff already...) But at this point I guess we're dueling reckons. Python is hard to optimize in a
by tonyg 3y ago
I don't think it's even more work. (V8 has the dynamic deopt stuff already...) But at this point I guess we're dueling reckons. Python is hard to optimize in a semantics-preserving way, of course, because the semantics are so bonkers. I just don't think it's stuff like subclassing int or inspecting the stack that makes it difficult.
- noelwelsh 3y agoI can agree with this take. What about Python do think makes it hard to optimize?
- tonyg 3y agoHmm. Off the top of my head, mind, but: - The bad API to foreign code that all the extensions depend on. - The nuts scoping rules, though I suppose throw enough static analysis at it and you might be OK. - Reference counting, which people depend upon. - locals(), globals(), though you could do some tricks with deoptimization there too I suppose. - Its metaclass system is pretty wacky. In general, just the overall ugliness of the design. It'd be jolly difficult to get beyond a toy operational model of the language, for example. There are so many corner cases to get right. Compare, say, Smalltalk, where there's an actual aesthetic to the metasystem (in all its 80s glory), and a full implementation can be remarkably small and simple; or anything else where you could plausibly capture an operational semantics without too much fuss.
- tonyg 3y agoOh! Neat: Shriram's group wrote a 2013 paper on semantics for Python. It's roughly what I would have expected it to be. It doesn't look like it addresses mutation of module bindings, for example, but perhaps the paper just doesn't show enough of the full model they built, or I'm misunderstanding the desugaring they are using. https://cs.brown.edu/~sk/Publications/Papers/Published/pmmwplck-python-full-monty/paper.pdf https://cs.brown.edu/~sk/Publications/Papers/Published/pmmwp...