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

PersistentHashWalkMapper: do not ignore comparison operator #146

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

matthiasdiener
Copy link
Contributor

@matthiasdiener matthiasdiener commented Sep 19, 2024

Consider the following example:

from pymbolic.primitives import Comparison, Variable

from pymbolic.mapper.persistent_hash import PersistentHashWalkMapper
from hashlib import sha256

expr1 = Comparison(Variable('_in0'), '<', Variable('_in1'))
expr2 = Comparison(Variable('_in0'), '>', Variable('_in1'))  # only differ in operator

pm1 = PersistentHashWalkMapper(sha256())
pm2 = PersistentHashWalkMapper(sha256())

pm1(expr1)
print(f"{pm1.key_hash.hexdigest()=}")

pm2(expr2)
print(f"{pm2.key_hash.hexdigest()=}")

before:

pm1.key_hash.hexdigest()='53780ab5ba3e7dc99573958a5a54fa8ed3f88972ab670832c1915653853bc0c4'
pm2.key_hash.hexdigest()='53780ab5ba3e7dc99573958a5a54fa8ed3f88972ab670832c1915653853bc0c4'  # same hash

after:

pm1.key_hash.hexdigest()='1a9b95805d65a0336e03cc7d8e2b7b2f335b1171b8d9e4743263ea2bc6e7763e'
pm2.key_hash.hexdigest()='9d3fa846784ec819667ea13b1447ef440dc994501a87c58f6fd9c0f66ddc4fbe'

(I guess there may be more occurrences of this kind of issue?)

@inducer inducer merged commit 861367f into inducer:main Sep 20, 2024
9 checks passed
@inducer
Copy link
Owner

inducer commented Sep 20, 2024

Oh boy. 🤦 I didn't even know this PersistentHashWalkMapper is there. It's pretty awful. #125 should make that entirely unnecessary. I'll add code to #125 to deprecate it.

@matthiasdiener matthiasdiener deleted the phwm-comparison branch September 20, 2024 16:55
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.

2 participants