-
Notifications
You must be signed in to change notification settings - Fork 372
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
Calling HyKeyword now looks up by string name, also remove name
from hy.core
#1977
Conversation
Why the change to You can write code like |
This prevents
Done! |
Why do you think so? The Python language reference says "The only required property is that objects which compare equal have the same hash value", not the converse. And there is no requirement that values of one type have different hashes from those of another type. For example, |
So then |
Not so. They're still not equal. |
huh, good point. I thought dictionary keys/sets were based on hash not equality. I guess that's only their hashability and not their identity as far as python is concerned. |
It's not documented well, but my impression is that the hashes of objects only affects the performance of dictionaries, not their semantics: you could have a dictionary of 1,000 non-equal objects with equal hashes and everything would work as you expect. The weird part, which is documented, is that an object needs to be hashable in order for the object to be allowed as a set element or dictionary key in the first place. |
Yeah it's not for true correctness, technically it's just a mild but easy performance optimization. |
So are you going to undo it? |
If there's a performance gain for something that small I don't see why not. Is there a reason not to do it? |
I would need to see clear evidence of a performance improvement in realistic code before approving a change that's intended to improve performance. I really doubt this will make a difference. |
Sure I can remove it, it's not something I feel strongly about. Just something I noticed and figured might be a nice-to-have while I was in the nearby code. |
Looks good, thanks. Would you please:
|
Done, as well as removing a couple references to the |
Thanks, Sunjay. In the future, before merging a PR (your own or somebody else's), could you rebase it onto master first? |
Oh yes, my bad. I will be sure to do that going forward! |
Closes #1974.