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

refactor[lang]: remove VyperNode __hash__() and __eq__() implementations #4433

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Jan 1, 2025

it is a performance and correctness footgun for the hash and eq implementations to recurse. for instance, two nodes from different source files should never compare equal (you can use deepequals to signal intention there).

i refactored the test suite by temporarily overriding the __ne__ implementation for VyperNode so that we can find all the != uses in the tests. the CI for this commit (0a9830b) passes (run https://github.com/vyperlang/vyper/actions/runs/12574333551/), and the training wheels are taken off in commit 71726ad.

What I did

How I did it

How to verify it

Commit message

Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

it is a performance and correctness footgun for the hash and eq
implementations to recurse. for instance, two nodes from different
source files should never compare equal (you can use deepequals to
signal intention there).

this commit temporarily overrides the `__ne__` implementation for
VyperNode so that we can find all the `!=` uses in the tests.
@charles-cooper charles-cooper marked this pull request as draft January 1, 2025 20:49
vyper/ast/nodes.py Fixed Show fixed Hide fixed
since we no longer need to worry about __hash__ and __eq__performance
@charles-cooper charles-cooper marked this pull request as ready for review January 1, 2025 21:11
@charles-cooper charles-cooper changed the title refactor[lang]: remove VyperNode __hash__ and __eq__ implementations refactor[lang]: remove VyperNode __hash__() and __eq__() implementations Jan 1, 2025
@charles-cooper charles-cooper added this to the v0.4.1 milestone Jan 2, 2025
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

Successfully merging this pull request may close these issues.

1 participant