[Mlir-commits] [mlir] [MLIR][Python] Remove partial LLVM APIs in python bindings (3/n) (PR #178984)

Jakub Kuderski llvmlistbot at llvm.org
Mon Feb 2 08:33:35 PST 2026


================
@@ -190,15 +192,16 @@ PyGlobals::lookupDialectClass(const std::string &dialectNamespace) {
 }
 
 std::optional<nb::object>
-PyGlobals::lookupOperationClass(llvm::StringRef operationName) {
+PyGlobals::lookupOperationClass(std::string_view operationName) {
   // Make sure dialect module is loaded.
-  auto split = operationName.split('.');
-  llvm::StringRef dialectNamespace = split.first;
+  size_t splitPos = operationName.find('.');
+  std::string_view dialectNamespace = operationName.substr(0, splitPos);
   if (!loadDialectModule(dialectNamespace))
     return std::nullopt;
 
   nb::ft_lock_guard lock(mutex);
-  auto foundIt = operationClassMap.find(operationName);
+  std::string operationNameStr(operationName);
+  auto foundIt = operationClassMap.find(operationNameStr);
----------------
kuhar wrote:

Do we need to materialize the string to find it? I'm surprised it doesn't allow for using string_view here.
This seems to have been added only in C++20: https://en.cppreference.com/w/cpp/container/unordered_map/find.html

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


More information about the Mlir-commits mailing list