[Mlir-commits] [mlir] [MLIR][Python] Add a function to register python-defined passes (PR #157850)

Maksim Levental llvmlistbot at llvm.org
Sun Sep 14 08:53:04 PDT 2025


makslevental wrote:

> Presumably that would mean C++-code gets to manage the lifetimes of the instances. 

You will never be able to skirt the issue that Python leaks references like a sieve. Already "functions with metadata" are classes because of closures - there's between "function that has tons of stuff in its closure" and "class with data" _as far as lifetime management is concerned_. There is no real way for C++ to control the lifetime of anything created in Python - not functions with data in their closures and definitely not data owned by classes which will have all sorts of their own references. The reason I strongly advocated (and will continue to advocate) functions is because at least there's some signal to the user they're doing questionable things wrt lifetime (ie they've used things in the closure).

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


More information about the Mlir-commits mailing list