I have provided you with the specific links to the implementation, together with the explanation.
The Python ==
operator is implemented for custom types using PyTypeObject (see tp_richcompare
); in PyUno (LibreOffice Python bridge), PyUNO_cmp implements that; it compares the objects that it wraps, the same way as the EqualUnoObjects
Basic function does.
I don’t know what was the basis of the " it was not possible to compare pyuno object in python using the ==
" understanding that you had. You have replaced the convoluted piece in your code with the plain ==
, and you see it works. I can only say that this is what I was talking about.
But this doesn’t mean that you will find it (or EqualUnoObjects
) behave as you expect in all cases. What they both do is compare if the two underlying references are pointing to the same UNO object. But consider this case: you call something like
a = sheet.getCellRangeByPosition(0,0,1,1)
b = sheet.getCellRangeByPosition(0,0,1,1)
The two objects refer to the same range on the same sheet. But they are the two different UNO objects, each created on demand, inside the getCellRangeByPosition
call: see the return new ScCellRangeObj
there. The objects are physically different; so both the Python’s a == b
, and Basoc’s EqualUnoObjects(a, b)
will give false.
This depends on how some specific functionality is implemented internally in LibreOffice. Some objects in the LibreOffice core are UNO objects themselves; then all references will point to the same actual implementation (like with a sheet object). Sometimes, there is no object in the core (like there’s no range object for A1:B2, until user wanted it - indeed, there is a huge number of possible ranges); so UNO objects are only created on demand, and there may be “twin” objects describing “same” thing. Indeed, it would be a natural wish to make improvements, like extending equality checks specifically for such objects, or implementing a way to avoid creation of a duplicated object, when there already is an identical object … everything is possible in software, just someone have to implement that. I write all this, just to set correct expectations.