5 ms·
> That is not language feature of Python but an implementation detail. So you're saying that the behavior of the `is` operator is implementation-defined? > va
by catnaroek 10y ago
> That is not language feature of Python but an implementation detail.
So you're saying that the behavior of the `is` operator is implementation-defined?
> values as a logical thing (where Python absolutely has compound values, including tuples)
The (informal, unspecified) metalanguage that you're using to reason about Python programs has compound values. Python itself doesn't.
- dragonwriter 10y ago> So you're saying that the behavior of the `is` operator is implementation-defined? No, the behavior has a standard definition: it reveals whether the operands refer to the same in-memory construct. Whether immutable values are stored in the same in-memory construct is, however, AIUI, implementation dependent.
- catnaroek 10y ago> Whether immutable values are stored in the same in-memory construct is, however, AIUI, implementation dependent. If I can't bind it to a variable, it isn't a value. You can't bind the list [1,2,3] to a variable, because Python has no such thing as the list [1,2,3].
- dragonwriter 10y agoI don't know why we are talking about lists, here, since (implementation details aside) lists in Python aren't conceptually values; for one thing, they aren't even immutable. If you meant not to change the subject from tuples, yes, its true that whether the tuple (1,2,3) -- which is logically a value -- has a unique in-memory representation is not guaranteed at the language level in Python (and, in fact, it does not in the most common implementation.)
- catnaroek 10y agoErr, sorry, yes, pretend I said “the tuple (1,2,3)”. Regarding in-memory representations, the whole point to using values is that you don't care about the representation. A value may be represented in a myriad different ways, but from within the language (as opposed to, say, using a memory debugger), you can't observe the difference. If you're allowed to probe differences between two representations of the same value, the value abstraction is leaky.