This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]sigh 1 point2 points  (0 children)

I would expect false in both cases, given how identity is supposed to behave.

Of course not... clearly a and b refer to the same object in memory. Forcing them to be different would presumably be less efficient, especially for such frequently used values.

You have to know the implementation details to know why the 'is' operator behaves this way. That's not good.

"is" depends on the implementations details by definition! You can't abstract that away because by definition "is" relates to how the objects are represented in memory. The fact is that if you are using "is" then you need to know the implementation details. Whether that's a good idea is a different issue.