[Mlir-commits] [llvm] [mlir] [mlir python] Port Python core code to nanobind. (PR #118583)

Stella Laurenzo llvmlistbot at llvm.org
Thu Dec 12 06:41:05 PST 2024


================
@@ -205,14 +316,13 @@ class PyDenseArrayAttribute : public PyConcreteAttribute<DerivedT> {
     EltTy dunderNext() {
       // Throw if the index has reached the end.
       if (nextIndex >= mlirDenseArrayGetNumElements(attr.get()))
-        throw py::stop_iteration();
+        throw nb::stop_iteration();
----------------
stellaraccident wrote:

It turns out there is an example later in this PR (for generic ir iterators). The C iteration protocol doesn't require c++ exceptions, which are the problems. It should have been implemented in PB/NB to be based on a return value vs an exception. ABC then that would just result in setting the python error status directly, which is cheap. 

Design flaw in pybind that propagated to nanobind.

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


More information about the Mlir-commits mailing list