[Mlir-commits] [mlir] [MLIR][Python] Improve Iterator performance. Don't `throw` in `dunderNext` methods. (PR #175377)
Maksim Levental
llvmlistbot at llvm.org
Sat Jan 10 21:27:44 PST 2026
================
@@ -194,13 +194,14 @@ nb::object PyBlock::getCapsule() {
// Collections.
//------------------------------------------------------------------------------
-PyRegion PyRegionIterator::dunderNext() {
+nb::typed<nb::object, PyRegion> PyRegionIterator::dunderNext() {
operation->checkValid();
if (nextIndex >= mlirOperationGetNumRegions(operation->get())) {
- throw nb::stop_iteration();
+ PyErr_SetNone(PyExc_StopIteration);
+ return nb::object();
----------------
makslevental wrote:
i.e. return `std::nullopt` here
https://github.com/llvm/llvm-project/pull/175377
More information about the Mlir-commits
mailing list