5 ms·
Somehow Python lets you distinguish “logically identical” things, though.
by catnaroek 10y ago
Somehow Python lets you distinguish “logically identical” things, though.
- pdonis 10y agoIf you're interested in properties other than logical identity, yes.
- catnaroek 10y agoBy definition identity checking is the finest-grained distinction you can make between things. If two things are identical, they can't possibly be different in any way. This is what philosophers call the “indiscernibility of identicals”, and, if it sounds like a tautology, it's because it is!
- pdonis 10y ago> By definition identity checking is the finest-grained distinction you can make between things By your definition, perhaps. The rest of us don't always use the word "identity" with this meaning. And since you don't own the English language, you don't get to tell the rest of us how to use words. > If two things are identical, they can't possibly be different in any way. Then by your definition, two Python tuples (1, 2, 3) are not identical. Which says absolutely nothing about how I can write programs using them, or what concepts of "identity" the operators in those programs can implement. > This is what philosophers call... We're talking about programming here, not philosophy.
- catnaroek 10y ago> Which says absolutely nothing about how I can write programs using them, I can write a program that treats all Python objects identically, by simply doing nothing. That doesn't make all Python objects actually identical. > We're talking about programming here, not philosophy. Programming is applied logic, which is a branch of philosophy.
- pdonis 10y ago> I can write a program that treats all Python objects identically, by simply doing nothing. That doesn't make all Python objects actually identical. Yes, you can. Thank you for proving my point that Python programs don't have to use your definition of identity. But that's a silly example. Here's an example that's not silly: in an earlier discussion you said dictionary keys have to be values--which would imply that dictionary key lookup must use your concept of "identity", so only two objects that are identical by your definition will behave as identical keys in a dictionary. But two distinct Python tuples (1, 2, 3), which are not identical by your definition, do behave as identical keys in a Python dictionary. In other words, Python dictionary key lookup does not use your concept of "identity". To everyone else, this means your concept of identity is simply not relevant. To you, it appears to mean that Python is violating Western logic. > Programming is applied logic, which is a branch of philosophy. To you, perhaps. Not to me. And not, I suspect, to most of the other programmers in this discussion.
- catnaroek 10y ago> But two distinct Python tuples (1, 2, 3), which are not identical by your definition, do behave as identical keys in a Python dictionary. The numbers 2 and 4 behave identically when passed to a function that tests whether its argument is an even number. Are 2 and 4 identical now? > To you, it appears to mean that Python is violating Western logic. This is the third time I'm saying I never said Python is violating Western logic. It's like saying I made a machine that violates gravity - it's literally impossible! Python just doesn't have compound values.
- pdonis 10y ago> The numbers 2 and 4 behave identically when passed to a function that tests whether its argument is an even number. Are 2 and 4 identical now? They are with respect to the even/odd property. So if that's the property I'm interested in, they're identical. They might not be if I'm interested in some other property. In other words, as dragonwriter has already pointed out, there is more than one concept of identity.
- dragonwriter 10y ago> By definition identity checking is the finest-grained distinction you can make between things. Yes, but there are different identities. "is" implements storage identity checking between python objects (a term broader than the sense in which you use "objects", which includes both what you call "objects" and representations of values). Logical identity checking between Python values (as well as object equivalence, but not identity, checking between Python "objects" in the sense you use the term) is done by "==". For most python value representations, the relationship between storage identity of the representation and logical identity of the value is undefined.
- catnaroek 10y ago> which includes both what you call "objects" and representations of values This is exactly what I'm saying is wrong: branching on the representations of values. > For most python value representations, the relationship between storage identity of the representation and logical identity of the value is undefined. If it's undefined, then how come I can query it?
- dragonwriter 10y ago> This is exactly what I'm saying is wrong: branching on the representations of values. Well, yes, its wrong in that (except in the cases where value identity and representation storage identity are guaranteed to be equivalent) you generally shouldn't do it (the exception being if you are building code to do something oomphaloskeptic where the purpose of code is to answer questions about what its own implementation is doing.) But the fact that doing that is possible in Python does not change the fact that Python does, in fact, support values (including compound values) with value-oriented semantics. > If it's undefined, then how come I can query it? The relation between physical identity of the storage representations and logical identity of the values they represent is undefined by the language specification. At runtime, every representation of a value has some storage identity, and you can query the relationship between that and the storage identity of another representation of a value. But the answer you get has no guaranteed correlation to whether the values represented by those representations are the same value (which you can also query.)