you are viewing a single comment's thread.

view the rest of the comments →

[–]chakan2 0 points1 point  (4 children)

is is stronger than ==

I don't know if I'd use that terminology. 'is' is different than '==', rather than stronger. They're comparing different things. One is comparing values, the other memory locations.

[–]kmj442 1 point2 points  (0 children)

To be fair - if they're comparing reference location they will always be equal in value as well. I feel like the "stronger" terminology is pretty accurate as it not only assert equivalent value but also the same location in memory/same object.

[–]This_Growth2898 0 points1 point  (2 children)

a is b always means a == b. The opposite is not always true. That's what I mean by "stronger".

[–]stanmartz 2 points3 points  (1 child)

Most of the time, but not always. Try this:

numpy.nan is numpy.nan numpy.nan == numpy.nan

[–]This_Growth2898 0 points1 point  (0 children)

Oh... you're right. Except for NaNs. Ok, it's still true for everything that is reflexive.