|
40 | 40 | from itertools import islice, groupby |
41 | 41 | from sage.rings.all import Integers, ZZ, Infinity |
42 | 42 | from sage.structure.richcmp import (richcmp_method, rich_to_bool, |
43 | | - richcmp, op_LT, op_GT) |
| 43 | + richcmp_item) |
44 | 44 |
|
45 | 45 |
|
46 | 46 | @richcmp_method |
@@ -75,7 +75,6 @@ def _repr_(self): |
75 | 75 | sage: Word(lambda x:x%3)._repr_() |
76 | 76 | 'word: 0120120120120120120120120120120120120120...' |
77 | 77 | """ |
78 | | - global word_options |
79 | 78 | if word_options['old_repr']: |
80 | 79 | return "Word over %s" % (str(self.parent().alphabet())[17:]) |
81 | 80 | return word_options['identifier'] + self.string_rep() |
@@ -122,7 +121,6 @@ def string_rep(self): |
122 | 121 | sage: print(w) |
123 | 122 | 0123401234012340123401234012340123401234... |
124 | 123 | """ |
125 | | - global word_options |
126 | 124 | l = word_options['truncate_length'] |
127 | 125 | letters = list(islice(self, int(l + 1))) |
128 | 126 | if len(letters) == l + 1: |
@@ -374,10 +372,9 @@ def __richcmp__(self, other, op): |
374 | 372 | else: |
375 | 373 | key_cs = cmp_key(cs) |
376 | 374 | key_co = cmp_key(co) |
377 | | - if key_cs < key_co: |
378 | | - return rich_to_bool(op, -1) |
379 | | - elif key_cs > key_co: |
380 | | - return rich_to_bool(op, 1) |
| 375 | + res = richcmp_item(key_cs, key_co, op) |
| 376 | + if res is not NotImplemented: |
| 377 | + return res |
381 | 378 |
|
382 | 379 | def _longest_common_prefix_iterator(self, other): |
383 | 380 | r""" |
@@ -705,7 +702,7 @@ def lex_less(self, other): |
705 | 702 | sage: t[:10].lex_less(t) |
706 | 703 | True |
707 | 704 | """ |
708 | | - return richcmp(self, other, op_LT) |
| 705 | + return self < other |
709 | 706 |
|
710 | 707 | def lex_greater(self, other): |
711 | 708 | r""" |
@@ -735,7 +732,7 @@ def lex_greater(self, other): |
735 | 732 | sage: t.lex_greater(t[:10]) |
736 | 733 | True |
737 | 734 | """ |
738 | | - return richcmp(self, other, op_GT) |
| 735 | + return self > other |
739 | 736 |
|
740 | 737 | def apply_morphism(self, morphism): |
741 | 738 | r""" |
|
0 commit comments