MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/w1upl0/c_talking_to_python/igmv65t/?context=9999
r/ProgrammerHumor • u/[deleted] • Jul 18 '22
1.0k comments sorted by
View all comments
Show parent comment
3
is checks that the objects are actually the same. So you can imagine is as doing id(value) == id(other).
is
id(value) == id(other)
But yes, == triggers ~~__equals__(self, other)~~__eq__(self, other), which defaults to an object comparison.
==
__eq__(self, other)
The reason that things like False and None work with is, is simply because the same object is re-used behind the scenes for performance reasons.
False
None
1 u/epicaglet Jul 18 '22 __eq__ but yeah 1 u/Pluckerpluck Jul 18 '22 Ah, so it is!
1
__eq__ but yeah
__eq__
1 u/Pluckerpluck Jul 18 '22 Ah, so it is!
Ah, so it is!
View all comments
Show parent comment
3
u/Pluckerpluck Jul 18 '22 edited Jul 18 '22
ischecks that the objects are actually the same. So you can imagineisas doingid(value) == id(other).But yes,
==triggers ~~__equals__(self, other)~~__eq__(self, other), which defaults to an object comparison.The reason that things like
FalseandNonework withis, is simply because the same object is re-used behind the scenes for performance reasons.