5 ms·
Or check that two dicts really are the same object, as opposed to two different dict objects that just happen to have the same keys/values?
by stevesimmons 3y ago
Or check that two dicts really are the same object, as opposed to two different dict objects that just happen to have the same keys/values?
- wodenokoto 3y agoI'm not sure I've ever had to do that. When is that a need?
- misnome 3y agoMy immediate first thought is, optimisation? If you know you’ve been the same object, you could skip e.g. comparison, or change update logic
- dist-epoch 3y agoThis kind of micro optimizations don't make much sense in Python. They complicate the code, and you are still 100 times slower than compiled languages.
- misnome 3y agoIt really… doesn’t have to complicate. And I disagree that optimising python code is never necessary. Not everybody is writing 100-line one-off glue scripts. Also, you are somewhat changing the topic from “what is an example of when you might want to is-compare two dicts”, no?