Comment by masklinn
19 hours ago
> That’s not “the normal way”, it’s just the case when the LHS is immutable.
It’s the default behaviour of |= if you override |, you need to specifically override |= to do otherwise.
> This behavior is congruent to C++
An excellent reason to do something else in and of itself.
> it’s documented and idiomatic.
Documenting a trap does not make it less of a trap. Innocently replacing | by |= induces a massive behavioural change which the user has little reason to expect, and which can easily lead to bugs due to mutating shared data.
> It’d be weird if the in-place operator deeply copied the LHS
I see you understand neither Python nor the behaviour of the | operator.
> problematic for a garbage-collected language in high throughput applications.
dict.update exists, if you specifically need to update the LHS in place it works just fine.
No comments yet
Contribute on Hacker News ↗