I'm trying to implement a poset class in sagex.  The following output indicates 
to me that __cmp__ gets called on the sagex class no matter what.  This means 
that partial ordering cannot be implemented in sagex (rather, it can, but can't 
take advantage of the comparison overloading that python offers).

I'm working with Bruhat ordering on permutations, but I've pared the example 
down to the following:

%sagex
cdef class po_sagex:
     def __init__(self):
         pass
     def __le__(self, other):
         return False

sage: a = po_sagex()
sage: b = po_sagex()
sage: print a <= b
True
sage: print b <= a
False

(note -- sometimes, True and False switch places in this example)


class po_python:
     def __init__(self):
         pass
     def __le__(self, other):
         return False

sage: c = po_python()
sage: d = po_python()
sage: print c <= d
False
sage: print d <= c
False



To work around this, I tried to implement a robust __cmp__ which returns None 
if the objects are incomparable, and no dice -- it barfs if __cmp__ doesn't 
return an integer.


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to