> I'm curious what the reason is to want to redefine 'is' for > immutables. If I understand Andrew, it's fix broken programs after > the fact (almost as if by time machine :-). > > It seems to me that 'is' should never be used for immutables except > for singletons like None. Perhaps PyChecker should warn about > inappropriate use of 'is' to compare two immutable objects, unless one > of them is None? This would be a cheaper solution than changing the > implementation. It wasn't my proposal, so I don't know the reason. However, I suspect that one motivation is just what you observed: "is" isn't a real good idea for immutables. One of the people in the comp.lang.python discussion suggested that with the change, "is" would be equivalent to "is substitutable for". Right now, "x is y" implies that x is substitutable for y, but the reverse is not always true. My own concern is that if someone writes expressions such as "x is 0" by mistake, the resulting program might always work on one implementation but fail on another.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4