Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an easy way to provide total ordering now that __cmp__ is deprecated/gone #49729

Closed
mrts mannequin opened this issue Mar 12, 2009 · 15 comments
Closed

Add an easy way to provide total ordering now that __cmp__ is deprecated/gone #49729

mrts mannequin opened this issue Mar 12, 2009 · 15 comments
Assignees
Labels
docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@mrts
Copy link
Mannequin

mrts mannequin commented Mar 12, 2009

BPO 5479
Nosy @loewis, @birkenfeld, @rhettinger, @mdickinson, @merwok, @florentx

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/rhettinger'
closed_at = <Date 2010-08-08.01:19:51.952>
created_at = <Date 2009-03-12.08:18:35.996>
labels = ['type-feature', 'library', 'docs']
title = 'Add an easy way to provide total ordering now that __cmp__ is deprecated/gone'
updated_at = <Date 2010-08-08.01:19:51.951>
user = 'https://bugs.python.org/mrts'

bugs.python.org fields:

activity = <Date 2010-08-08.01:19:51.951>
actor = 'rhettinger'
assignee = 'rhettinger'
closed = True
closed_date = <Date 2010-08-08.01:19:51.952>
closer = 'rhettinger'
components = ['Documentation', 'Library (Lib)']
creation = <Date 2009-03-12.08:18:35.996>
creator = 'mrts'
dependencies = []
files = []
hgrepos = []
issue_num = 5479
keywords = []
message_count = 15.0
messages = ['83490', '83491', '83499', '83501', '83502', '83510', '83528', '83574', '102315', '102400', '102401', '102402', '102403', '102412', '113228']
nosy_count = 8.0
nosy_names = ['loewis', 'georg.brandl', 'rhettinger', 'mark.dickinson', 'LambertDW', 'eric.araujo', 'mrts', 'flox']
pr_nums = []
priority = 'normal'
resolution = 'accepted'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue5479'
versions = ['Python 2.7', 'Python 3.2']

@mrts
Copy link
Mannequin Author

mrts mannequin commented Mar 12, 2009

@mrts mrts mannequin assigned birkenfeld Mar 12, 2009
@mrts mrts mannequin added docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Mar 12, 2009
@lambertdw
Copy link
Mannequin

lambertdw mannequin commented Mar 12, 2009

That's the best version I recall seeing at activestate.

Still, I'd deprecate and remove > and >= from mathematics.

@loewis
Copy link
Mannequin

loewis mannequin commented Mar 12, 2009

What is the purpose of this submission? What do you want to happen about
Python?

@lambertdw
Copy link
Mannequin

lambertdw mannequin commented Mar 12, 2009

(As I recall) in python-dev mailing list Ray claimed he could clean up a
cited active state recipe to address this issue. He succeeded to the
extent I'm aware---he's the author of
http://code.activestate.com/recipes/576685/.

I haven't used the redundant >, >= comparisons operators in code since
1981. The chances of simplifying python by removing them from the
language are None, but the mistake predates python by 10**n years, where
(3 <= n <= 7) or (7 >= n >= 3).

@loewis
Copy link
Mannequin

loewis mannequin commented Mar 12, 2009

Then why was this classified as a documentation issue? And why did Mart
Sömmermaa submit it, and not Raymond? AFAICT, Raymond said he would
propose something when it's ready (which I assume it currently isn't).

@mrts
Copy link
Mannequin Author

mrts mannequin commented Mar 13, 2009

Then why was this classified as a documentation issue?

As the documentation section of
http://docs.python.org/reference/datamodel.html#object.\_\_lt__ needs to
be updated as well to mark the eventual solution as the recommended easy
way to provide total ordering.

And why did Mart Sömmermaa submit it, and not Raymond? AFAICT, Raymond
said he would propose something when it's ready (which I assume it
currently isn't).

Raymond's recipe at http://code.activestate.com/recipes/576685/ looks
more or less complete, do you feel that his posting on the mailing list
does not count as proposal? I submitted the feature request instead of
him because I was the one who noticed the problem (as discussed on the
mailing list) and felt "responsible" to report it here.

@loewis
Copy link
Mannequin

loewis mannequin commented Mar 13, 2009

As the documentation section of
http://docs.python.org/reference/datamodel.html#object.\_\_lt__ needs to
be updated as well to mark the eventual solution as the recommended easy
way to provide total ordering.

This is the 2.6 version. What about the 3.0 version in

http://docs.python.org/3.0/reference/datamodel.html#object.\_\_lt__

needs to be updated?

Raymond's recipe at http://code.activestate.com/recipes/576685/ looks
more or less complete, do you feel that his posting on the mailing list
does not count as proposal? I submitted the feature request instead of
him because I was the one who noticed the problem (as discussed on the
mailing list) and felt "responsible" to report it here.

I see. So it's a feature request.

@mrts
Copy link
Mannequin Author

mrts mannequin commented Mar 14, 2009

This is the 2.6 version. What about the 3.0 version in
http://docs.python.org/3.0/reference/datamodel.html#object.\_\_lt__
needs to be updated?

When functools.total_ordering (whether it lands in functools is open)
lands that section should be amended in the lines of the following:

"There are no implied relationships among the comparison operators. The
truth of x==y does not imply that x!=y is false. Accordingly, when
defining __eq__(), one should also define __ne__() so that the operators
will behave as expected.

However, given a class defining one or more ordering methods,
functools.total_ordering_ class decorator can be used to fill in the
rest. Please see the documentation of functools.total_ordering_ for
further details."

@rhettinger rhettinger assigned rhettinger and unassigned birkenfeld Apr 25, 2009
@rhettinger
Copy link
Contributor

See r79730.

Leaving open until tests are written and all is forward ported to 3.2.

@merwok
Copy link
Member

merwok commented Apr 5, 2010

Hello

Small documentation question: Does the expression “total ordering” have established usage in maths or computer science? Its meaning is not obvious to the non-maths person that I am.

Regards

@mdickinson
Copy link
Member

Yes, it's a standard mathematics term.

http://en.wikipedia.org/wiki/Total_order

@rhettinger
Copy link
Contributor

@merwok
Copy link
Member

merwok commented Apr 5, 2010

Thanks for the link. Please include it in the future doc if you judge it useful for a large number of users.

I’m still wondering if “total_ordering” is the best name for a decorator that fills the blanks to provide total ordering.

Regards

@lambertdw
Copy link
Mannequin

lambertdw mannequin commented Apr 5, 2010

http://en.wikipedia.org/wiki/Total_order

For pair of items from a set, (that's the total)
if a <= b and b <= c then a <= c (part of the order)
if a <= b and b <= a then a compares the same as b, a == b, (the
other part of the order)

On Mon, 2010-04-05 at 19:46 +0000, Éric Araujo wrote:

Éric Araujo <merwok@netwok.org> added the comment:

Hello

Small documentation question: Does the expression “total ordering” have established usage in maths or computer science? Its meaning is not obvious to the non-maths person that I am.

Regards

----------


Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue5479\>


@rhettinger
Copy link
Contributor

Applied in r79810
Thanks for the suggestion.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants