This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients eric.smith, larry, levkivskyi, ncoghlan
Date 2018-01-23.02:36:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1516674978.31.0.467229070634.issue32513@psf.upfronthosting.co.za>
In-reply-to
Content
For the ordering operators, my only question would be whether or not I can rely on them to act like functools.total_ordering: if I supply __eq__ and one of the ordering operators (e.g. __lt__), will dataclasses make sure the other three ordering operators are consistent with those base methods? Or will it bypass them and act directly on the underlying fields?

My suggestion would be to say that if any of __lt__, __le__, __gt__ or __ge__ are defined, then data classes will implicitly generate the other methods based on functools.total_ordering semantics, and will only reference the underlying fields directly if *none* of them are defined. Otherwise I can see folks defining a single method like "__lt__", and being surprised when they end up with inconsistent comparison behaviour.
History
Date User Action Args
2018-01-23 02:36:18ncoghlansetrecipients: + ncoghlan, larry, eric.smith, levkivskyi
2018-01-23 02:36:18ncoghlansetmessageid: <1516674978.31.0.467229070634.issue32513@psf.upfronthosting.co.za>
2018-01-23 02:36:18ncoghlanlinkissue32513 messages
2018-01-23 02:36:17ncoghlancreate