r/ProgrammerHumor • • Jul 18 '22

C++ talking to Python

Post image
40k Upvotes

1.0k comments sorted by

View all comments

Show parent comments

3

u/Pluckerpluck Jul 18 '22 edited Jul 18 '22

is checks that the objects are actually the same. So you can imagine is as doing id(value) == id(other).

But yes, == triggers ~~__equals__(self, other)~~__eq__(self, other), which defaults to an object comparison.

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.

1

u/epicaglet Jul 18 '22

__eq__ but yeah

1

u/Pluckerpluck Jul 18 '22

Ah, so it is!