Ok. To make up for my confusion, I took a deeper look at this.
In Maya2022 Py2 it still works, and I determined the .__hash__
method comes from
<class 'pymel.util.utilitytypes.ProxyUnicode'>
inherited class.
So I’m hypothesizing that the object acts kind of like a unicode string. This led me to test if hash(vtx) == hash(str(vtx))
, and that’s exactly the case. So hypothesis confirmed.
In Py3, the MeshVertex
class eventually inherits from
<class 'pymel.util.utilitytypes.proxyClass.<locals>.Proxy'>
instead of the ProxyUnicode
Looking at the implementation of pymel.util.utilitytypes.ProxyUnicode
, there’s this comment:
# Note - for backwards compatibility reasons, PyNodes still inherit from
# ProxyUnicode, even though we are now discouraging their use 'like strings',
# and ProxyUnicode itself has now had so many methods removed from it that
# it's no longer really a good proxy for unicode.
So they’re discouraging that usage anyway. Unfortunately, I can’t find where it really diverges between Py2 and Py3. The code is essentially the same for both versions, so I would chalk it up to the difference between the two.
If worse comes to worse, you could probably monkey-patch some classes so that the .__hash__
method returns the hash of the string of the object, and that would give you equivalent behavior… but that’s one of those “last resort” kind of things that I wouldn’t actually recommend.