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

Oscar Benjamin oscar.j.benjamin at gmail.com
Fri Apr 15 16:33:44 EDT 2016

On 15 April 2016 at 18:54, Jim J. Jewett <jimjjewett at gmail.com> wrote:
> [2A] Do you want to promise that replacing a value with a
> non-identical object *will* trigger a version_tag update *even*
> if the objects are equal?
> I would vote no, but I realize backwards-compatibility may create
> such a promise implicitly.

It needs to trigger a version update. Equality  doesn't guarantee any
kind of equivalence in Python. It's not even guaranteed that a==b will
come to the same value if evaluated twice in a row.

An example:

>>> from fractions import Fraction as F
>>> F(1) == 1
>>> d = globals()
>>> d['a'] = F(1)
>>> a.limit_denominator()
Fraction(1, 1)
>>> d['a'] = 1
>>> a.limit_denominator()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'int' object has no attribute 'limit_denominator'


More information about the Python-Dev mailing list