Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

baseDict eq should happen on object id instead of object data #343

Open
typemytype opened this issue Feb 25, 2021 · 0 comments
Open

baseDict eq should happen on object id instead of object data #343

typemytype opened this issue Feb 25, 2021 · 0 comments

Comments

@typemytype
Copy link
Member

The problem was detected while holding notifications of anchor objects. The anchor data didnt change but the notifications was not held cause the key based on the object was already in the held notifications.

Compare BaseDict object on id not on object data, similar as other defcon objects like components, contours.

Will push a PR in a bit

import defcon

c1 = defcon.Component()
c2 = defcon.Component()
c1.baseGlyph = c2.baseGlyph = "foo"

print(c1 == c2)
print(c1 in [c2])

a1 = defcon.Anchor()
a2 = defcon.Anchor()
a1.name = a2.name = "foo"
a1.x = a2.x = 100
a1.y = a2.y = 100

print(a1 == a2)
print(a1 in [a2])

class CmpAnchor(defcon.Anchor):
    
    def __eq__(self, other):
        return id(self) == id(other)
    

a1 = CmpAnchor()
a2 = CmpAnchor()
a1.name = a2.name = "foo"
a1.x = a2.x = 100
a1.y = a2.y = 100

print(a1 == a2)
print(a1 in [a2])
@typemytype typemytype changed the title baseDict eq should happen on object id instead of object data``` baseDict eq should happen on object id instead of object data Feb 25, 2021
typemytype added a commit that referenced this issue Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant