[Python-Dev] Why doesn't functools.total_ordering
use the existing ordering methods? (original) (raw)
Lennart Regebro regebro at gmail.com
Tue Apr 26 09:10:10 CEST 2011
- Previous message: [Python-Dev] Why doesn't `functools.total_ordering` use the existing ordering methods?
- Next message: [Python-Dev] cpython (2.7): #11901: add description of how bitfields are laid out to hexversion docs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, Apr 25, 2011 at 20:43, cool-RR <cool-rr at cool-rr.com> wrote:
Hello, Today I was trying to use
totalordering
for the first time. I was expecting that in order to implement e.g.x > y
it would donot x < y and_ _not x == y
, assuming that_lt_
and_eq_
are defined. But I see it just doesy < x
, which is problematic. For example if you have a class that is decorated bytotalordering
, and implements only_lt_
and_eq_
, then trying to dox < y
will result in infinite recursion. Why not havetotalordering
work in the way I suggested?
This has been partly fixed for Python 3.2, although it can still happen if you compare two types that both use the total_ordering decorator. See http://bugs.python.org/issue10042 .
-- Lennart Regebro: http://regebro.wordpress.com/ Porting to Python 3: http://python3porting.com/
- Previous message: [Python-Dev] Why doesn't `functools.total_ordering` use the existing ordering methods?
- Next message: [Python-Dev] cpython (2.7): #11901: add description of how bitfields are laid out to hexversion docs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]