[Python-Dev] Second post: PEP 557, Data Classes

Eric V. Smith eric at trueblade.com
Sun Nov 26 10:14:24 EST 2017


On 11/26/2017 3:48 AM, Eric V. Smith wrote:
> While creating an issue for this 
> (https://github.com/ericvsmith/dataclasses/issues/88), it occurs to me 
> that the class-level parameter really should be "order" or "orderable", 
> not "compare". It made more sense when it was called "cmp", but 
> "compare" now seems wrong.
> 
> Because "eq" says "can I compare two instances", and what's currently 
> called "compare" is "can I order two instances". Nick had a similar 
> suggestion before the PEP was written 
> (https://mail.python.org/pipermail/python-ideas/2017-May/045740.html).
> 
> The field-level parameter should stay "compare", because it's used for 
> both __gt__ and friends, as well as __eq__ and __ne__. It's saying "is 
> this field used in all of the comparison methods".

I created https://github.com/ericvsmith/dataclasses/issues/90 for this. 
I think I'll leave 'eq' alone, and change 'compare' to 'order', for the 
class-level parameter name.

Eric.


More information about the Python-Dev mailing list