Hacker News new | ask | show | jobs
by wallnuss 3136 days ago
The blog is fun introduction into JIT compiler, but the big thing that is missing and that makes Python a hard problem for JIT is supporting Objects. From http://blog.kevmod.com/2017/02/personal-thoughts-about-pysto...

    I'll try to just talk about what makes Python hard to run quickly (especially as compared to less-dynamic languages like JS or Lua).

    The thing I wish people understood about Python performance is that the difficulties come from Python's extremely rich object model, not from anything about its dynamic scopes or dynamic types.  The problem is that every 
    operation in Python will typically have multiple points at which the user can override the behavior, and these features are used, often very extensively.  Some examples are inspecting the locals of a frame after the frame 
    has exited, mutating functions in-place, or even something as banal as overriding isinstance.  These are all things that we had to support, and are used enough that we have to support efficiently, and don't have analogs in 
    less-dynamic languages like JS or Lua.
1 comments

Newer versions of Python have an in-band way of detecting if an object has been overridden. Foreseeably this could have been done completely internal to the VM. Defaulting to closed and requiring an explicit step to override behavior would have made optimizing Python far easier.