Can the bytecode optimization code be farmed out to LLVM?

I was looking for issues to help with under performance. I noticed this pattern amongst some issues:

  1. gh-152215: Add uop peepholes for folded stack shuffles by cocolato · Pull Request #153035 · python/cpython · GitHub
  2. `LOAD_FAST_BORROW; POP_TOP` pairs should be removed · Issue #152600 · python/cpython · GitHub

It feels like Python codebase is duplicating optimizations with other runtimes/compilers. It reminds me of https://arrow.apache.org/ . Could these optimizations be implemented by converting bytecode to LLVM IR → run a list of LLVM functions/passes → convert back?

1 Like

That would mean that python would not be able to optimise unless you have a working llvm on your system right?

Sure that is an issue?

I imagine these will be C++ libraries so you would link it into the binary.

Numba does this