https://bugs.documentfoundation.org/show_bug.cgi?id=126487
Neil Roberts <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |[email protected] Resolution|--- |NOTABUG --- Comment #9 from Neil Roberts <[email protected]> --- It looks like the == operator as suggested in comment #2 already works. For example: import uno localContext = uno.getComponentContext() a = localContext.ServiceManager b = localContext.ServiceManager print(f"id(a) -> {id(a)}") print(f"id(b) -> {id(b)}") print(f"a == b -> {a == b}") This prints: id(a) -> 140688621675472 id(b) -> 140688615666448 a == b -> True This is implemented in PyUNO_cmp in pyuno.cxx. I also tested it in LibreOffice 6.2.0 and with a remote connection and it all works. Maybe it doesn’t work in the specific case that Konstantin is talking about because some API methods create new UNO objects to wrap internal objects every time they are called. This seems to be a common source of confusion (see #137664 and probably others). I guess it would be theoretically possible to make id(a)==id(b) if we had some sort of lookup table for incoming objects so we could map them to same Python object if we see the same object again. However this would add overhead and probably isn’t worth it because being able to check if two objects are the same is probably enough in most use cases. I’m closing the bug as NOTABUG because it doesn’t seem like a general pyuno problem but a problem specific to the API that is returning the cell objects. Feel free to open another bug if you think that API should be returning the same UNO object, or maybe provide some other way to check if they refer to the same cell. -- You are receiving this mail because: You are the assignee for the bug.
