Skip to content

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

Closed

Description

@mrts
mannequin
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']

Activity

  1. added
    docs
    stdlib
    type-feature
    on Mar 12, 2009
  2. lambertdw commented on Mar 12, 2009

    lambertdwmannequin
    Mannequin

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

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

  3. loewis commented on Mar 12, 2009

    loewismannequin
    Mannequin

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

  4. lambertdw commented on Mar 12, 2009

    lambertdwmannequin
    Mannequin

    (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).

  5. loewis commented on Mar 12, 2009

    loewismannequin
    Mannequin

    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).

  6. mrts commented on Mar 13, 2009

    mrtsmannequin
    MannequinAuthor

    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.

  7. loewis commented on Mar 13, 2009

    loewismannequin
    Mannequin

    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.

  8. mrts commented on Mar 14, 2009

    mrtsmannequin
    MannequinAuthor

    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."

  9. rhettinger commented on Apr 4, 2010

    @rhettinger
    Contributor

    See r79730.

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

  10. merwok commented on Apr 5, 2010

    @merwok
    Member

    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

  11. mdickinson commented on Apr 5, 2010

    @mdickinson
    Member

    Yes, it's a standard mathematics term.

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

  12. rhettinger commented on Apr 5, 2010

    @rhettinger
    Contributor
  13. merwok commented on Apr 5, 2010

    @merwok
    Member

    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

  14. lambertdw commented on Apr 5, 2010

    lambertdwmannequin
    Mannequin

    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\>


  15. rhettinger commented on Aug 8, 2010

    @rhettinger
    Contributor

    Applied in r79810
    Thanks for the suggestion.

  16. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

docsstdlibtype-feature

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions