Author: Emma Smith
Created at: 2025-11-22 18:11
Number: 193
Clean content: Thank you for bringing this up! I think memoryview could be a very appealing option for demonstrating Rust. Rust’s generics could make index a lot easier to implement as you say. I also think it has made me reconsider where to draw the line of where it is okay to re-write things in Rust. I want to start this by re-iterating that we do not want to go and just re-implement everything and anything in Rust to start with. At least until we have a lot more experience with Rust in CPython, and given contributors time to learn and try working with Rust, we should select up to a few experimental changes to make, and review our experiences after making those changes. Areas re-written in Rust should have a justification for doing so, like memoryview. We should also consider if the most active contributors to that portion of the codebase are comfortable with Rust being introduced. That being said I think we could expand where Rust could be implemented to include built-in objects, or really any part of the interpreter, if we also keep a C fallback of the implementation. For memoryview, we could keep the current implementation as a compile-time fallback and introduce a Rust version that takes advantage of it’s meta-programming (if needed) and generics. This may mean we’d need to maintain two versions of certain parts of the interpreter for a little while, but I think getting more experience across the code base would be worth the extra effort. The maintenance effort of keeping two implementations should be considered  as part of evaluating where to introduce Rust. With C compile-time fallbacks, there should be no cause for concern on portability or bootstrapping. This seems like a nice compromise between the very limited “Rust only in extension modules” and “Rust can go anywhere and we need to figure out bootstrapping”. Obviously the trade-off is maintenance burden, but I think if we’re smart about what parts we implement in Rust, we can minimize the effort. Curious what others think!
