[Python-Dev] PEP 509: Add a private version to dict

Victor Stinner victor.stinner at gmail.com
Tue Jan 12 09:25:22 EST 2016


Well, it was just a remark.

2016-01-12 0:35 GMT+01:00 Andrew Barnert <abarnert at yahoo.com>:
> 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?

Optimizers don't have to rely on this exactly behaviour. Not
incrementing the version on such case avoids dictionary lookups in the
guard.

My current patch does not increment if the value is the same, and I'm
unable to see any performance regression on *micro* benchmarks:
https://bugs.python.org/issue26058

So I'm in favor of making guards as efficient as possible and not
increment the version in dict ;-)

Victor


More information about the Python-Dev mailing list