# Can the bytecode optimization code be farmed out to LLVM?

**URL:** <https://discuss.python.org/t/can-the-bytecode-optimization-code-be-farmed-out-to-llvm/108140>\
**Category:** Ideas\
**Tags:** performance\
**Created:** [July 13, 2026, 5:27pm UTC](https://discuss.python.org/t/can-the-bytecode-optimization-code-be-farmed-out-to-llvm/108140 "2026-07-13T17:27:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SurenNihalani](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/surennihalani/32/35190_2.png) [@SurenNihalani](https://discuss.python.org/u/SurenNihalani)\
**Post date:** [July 13, 2026, 5:27pm UTC](https://discuss.python.org/t/can-the-bytecode-optimization-code-be-farmed-out-to-llvm/108140/1 "2026-07-13T17:27:28Z")

</div>

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](https://github.com/python/cpython/pull/153035)
2. [`LOAD_FAST_BORROW; POP_TOP` pairs should be removed · Issue #152600 · python/cpython · GitHub](https://github.com/python/cpython/issues/152600)

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

---

<div class="post-metadata">

**Author:** ![barry-scott](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@barry-scott](https://discuss.python.org/u/barry-scott)\
**Post date:** [July 13, 2026, 8:09pm UTC](https://discuss.python.org/t/can-the-bytecode-optimization-code-be-farmed-out-to-llvm/108140/2 "2026-07-13T20:09:17Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![SurenNihalani](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/surennihalani/32/35190_2.png) [@SurenNihalani](https://discuss.python.org/u/SurenNihalani)\
**Post date:** [July 13, 2026, 8:22pm UTC](https://discuss.python.org/t/can-the-bytecode-optimization-code-be-farmed-out-to-llvm/108140/3 "2026-07-13T20:22:48Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![jorenham](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jorenham/32/27806_2.png) [@jorenham](https://discuss.python.org/u/jorenham)\
**Post date:** [July 13, 2026, 9:28pm UTC](https://discuss.python.org/t/can-the-bytecode-optimization-code-be-farmed-out-to-llvm/108140/4 "2026-07-13T21:28:35Z")

</div>

Numba does this

> **[GitHub - numba/numba: NumPy aware dynamic Python compiler using LLVM](https://github.com/numba/numba)**
>
> NumPy aware dynamic Python compiler using LLVM
