@@ -100,12 +100,25 @@ Module contents
100100 ignored.
101101
102102 - *eq *: If true (the default), an :meth: `~object.__eq__ ` method will be
103- generated. This method compares the class as if it were a tuple
104- of its fields, in order. Both instances in the comparison must
105- be of the identical type.
103+ generated.
106104
107- If the class already defines :meth: `!__eq__ `, this parameter is
108- ignored.
105+ This method compares the class by comparing each field in order. Both
106+ instances in the comparison must be of the identical type.
107+
108+ If the class already defines :meth: `!__eq__ `, this parameter is ignored.
109+
110+ .. versionchanged :: 3.13
111+ The generated ``__eq__ `` method now compares each field individually
112+ (for example, ``self.a == other.a and self.b == other.b ``), rather than
113+ comparing tuples of fields as in previous versions.
114+
115+ This change makes the comparison faster but it may alter results in cases
116+ where attributes compare equal by identity but not by value (such as
117+ ``float('nan') ``).
118+
119+ In Python 3.12 and earlier, the comparison was performed by creating
120+ tuples of the fields and comparing them (for example,
121+ ``(self.a, self.b) == (other.a, other.b) ``).
109122
110123 - *order *: If true (the default is ``False ``), :meth: `~object.__lt__ `,
111124 :meth: `~object.__le__ `, :meth: `~object.__gt__ `, and :meth: `~object.__ge__ ` methods will be
0 commit comments