
On Jan 11, 2016, at 15:24, Victor Stinner <victor.stinner@gmail.com> wrote:
2016-01-12 0:07 GMT+01:00 Gregory P. Smith <greg@krypto.org>:
Changes =======
(...)
Please be more explicit about what tests you are performing on the values. setitem's "if the value is different" really should mean "if value is not dict['key']". similarly for update, there should never be equality checks performed on the values. just an "is" test of it they are the same object or not.
Ok, done. By the way, it's also explained below: values are compared by their identify, not by their content.
For best dict efficiency, we can not implement this micro-optimization (to avoid a potential branch misprediction in the CPU) and always increase the version. But for guards, the micro-optimization can avoid a lot of dictionary lookups, especially when a guard watches for a large number of keys.
Are you saying that d[key] = d[key] may or may not increment the version, so any optimizer can't rely on the fact that it doesn't? If so, that seems reasonable. (The worst case in incrementing the version unnecessarily is that you miss an optimization that would have been safe, right?).