4 ms·
The first third of this seems to just be complaining that it's not obvious when two objects are actually the same object, and that if you mistake identity-relat
by hansvm 1y ago
The first third of this seems to just be complaining that it's not obvious when two objects are actually the same object, and that if you mistake identity-related operators for other operators then you'll have a bad day.
That's a fair critique. It's a little weird that `is` and friends have dedicated, short, nice syntax.
On the other hand, most compiled languages are compatible with an implementation which admits the following optimization:
const a: u32 = 42;
const b: u32 = 42;
assert(&a == &b);
The language usually doesn't guarantee that different immutable variables have dedicated memory on the stack, or that they even live on the stack in the first place.
That's the same class of error we're seeing here, and even among popular interpreted languages Python is by no means unique. I might get to the bottom 2/3 of the doc later, but the rest was off-putting enough that I don't know I'll bother.
- hmry 1y agoYeah, it would be much clearer if instead of an `a is b` operator, there was a `same_object(a, b)` built-in method.