[Mlir-commits] [mlir] [MLIR][CAPI][Python] Add support for querying memory effect instances (PR #213459)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Aug 1 08:52:16 PDT 2026
================
@@ -30,7 +30,6 @@ extern "C" {
DEFINE_C_API_STRUCT(MlirMemoryEffect, void);
DEFINE_C_API_STRUCT(MlirMemoryEffectInstance, void);
-DEFINE_C_API_STRUCT(MlirMemoryEffectInstancesList, void);
----------------
PragmaTwice wrote:
Removing `MlirMemoryEffectInstancesList` is intentional. Keeping it while adding query support would have the following costs:
- We need to define and maintain ownership and lifetime rules for both the list and its elements, including the difference between callback-borrowed and caller-owned lists.
- A usable list would require a much larger C API: create, destroy, size, get item, append, and probably clone or ownership-transfer operations.
- Python could not use its built-in list. We would need to implement and maintain a custom list-like wrapper, including iteration, indexing, type stubs, and lifetime handling. It would still be less convenient to use and compose than a normal Python list.
With the new design, Python can return and combine ordinary lists, while C callers only copy the individual instances they need to keep. The migration is mechanical: producers return or pass a batch of effects instead of appending to a supplied list. Removing the old type avoids maintaining both models going forward.
https://github.com/llvm/llvm-project/pull/213459
More information about the Mlir-commits
mailing list