[Mlir-commits] [mlir] [MLIR] [PYTHON] A few improvements to the Python bindings (PR #131686)

Sergei Lebedev llvmlistbot at llvm.org
Tue Mar 18 01:25:58 PDT 2025


================
@@ -450,6 +458,9 @@ class PyBlockList {
 
   PyBlock dunderGetItem(intptr_t index) {
     operation->checkValid();
+    if (index < 0) {
+      index += dunderLen();
+    }
     if (index < 0) {
       throw nb::index_error("attempt to access out of bounds block");
     }
----------------
superbobry wrote:

It can still be negative, right?

```
xs = [1, 2, 3]
xs[-42]
```

https://github.com/llvm/llvm-project/pull/131686


More information about the Mlir-commits mailing list