# Comparing Perspective Object - Never the same?

**URL:** <https://forum.inductiveautomation.com/t/comparing-perspective-object-never-the-same/53085>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [November 15, 2021, 6:25pm UTC](https://forum.inductiveautomation.com/t/comparing-perspective-object-never-the-same/53085 "2021-11-15T18:25:50Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 15, 2021, 7:10pm UTC](https://forum.inductiveautomation.com/t/comparing-perspective-object-never-the-same/53085/2 "2021-11-15T19:10:50Z")

</div>

The expression equals operator is using ‘shallow’ quality; under the hood, for various reasons, this is ultimately becoming a simple identity check.

We could potentially make this smarter in the future, but it won’t help you much right now.  
In the short term, you can lean on Python a bit; use `runScript` to convert Perspective types to equivalent Python representation, then run your equality comparison on those:

```auto
def sanitize_tree(element):
    if hasattr(element, ' __iter__'):
        if hasattr(element, 'keys'):
            return dict((k, sanitize_tree(element[k])) for k in element.keys())
        else:
            return list(sanitize_tree(x) for x in element)
    return element

def deepEquals(left, right):
    return sanitize_tree(left) == sanitize_tree(right)

```

(see [this post](https://forum.inductiveautomation.com/t/function-to-convert-json-string-or-python-dict-into-objectwrapper/32861/16) for more on the `sanitize_tree` function)

Can be used basically the same as your existing:  
`runScript("utils.deepEquals", 0, {view.custom.left}, {view.custom.right})`  
 ![java_87kXhe](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/8/38877d5d1640bfab9d9b740c3aa88e031c27d2f3.png)  
 ![java_HTQddC](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/f/5f0389119276e8435c617922108098ad7d5151fe.png)  
 ![java_avv9fA](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/6/06a4ccdadb1b28c37d8b7858121b31a642c3262a.png)

---

_[View the full topic](https://forum.inductiveautomation.com/t/comparing-perspective-object-never-the-same/53085)._
