-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Deep Down, explain or remove example #301
Comments
In retrospect, maybe the example could be expanded and explained.
The |
Thanks for starting the discussion, I think
And yeah, I agree this is a simpler way to convey it, so I'll consider this too :) |
Thank you for thinking about5 this. The issues is 'equivalence'. By default, instances use
|
I think thats's a good way to explain it. Also, thanks for sharing your notes :) |
This example:
It may not be explainable because the documentation of
__hash__
is borked. It never discusses what a hash of an instance entails. It also adds the bizarre restriction to user defined hash and equality functions that "x==y
implies ...x is y
" so all custom hash functions and custom equality must incorporateid(self)
and provide no more or less information thanid(self)
or cause issues as in "Disorder within Order".The code snippet works simply because the
WTF()
on both sides of an equality are likely to have the same id (memory reuse). And that the hash happens to return the same value for the same instance type at the same location.Consider this example showing that the contents are ignored:
Therefore, I recommend removing this example and just relating to a later
wtff
. (f
is for flying).The text was updated successfully, but these errors were encountered: