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