2 ms·
PyPy is a JIT for Python that's usually faster than the CPython interpreter, but not quite as fast as LuaJIT. One of the reasons is that Python is a relatively
by yorwba 9y ago
PyPy is a JIT for Python that's usually faster than the CPython interpreter, but not quite as fast as LuaJIT.
One of the reasons is that Python is a relatively more complex language with stuff like varargs or dict-unpacking that need to be considered at every call, and properties/__getattr__/__getattribute___ inserting themselves into the path for a simple field access. That might not be much worse than Lua's metatables, but the standard library makes use of those features in lots of places, so you can't really avoid them.
Additionally, IIRC LuaJIT uses hand-rolled assembly where necessary, while PyPy is written in Python and converted to C by the RPython toolchain using a process that involves abstract interpretation of the bytecode obtained by reflection on live code objects. That allows making use of all kinds of complex metaprogramming at initialization time to simplify the implementation, but the generated C code is unlikely to be maximally efficient.