> There is one good reason for implementing both __cmp__() and rich > comparisons: when comparing is expensive, it makes sense to call cmp() > directly if you need the full three-way compare to branch. (Decimal is > a good example of this -- at least it was when I originally wrote it, > and it probably still has the same need now.) Another good example comes from the <, <=, >, >= operators on lists. These require you to step through the lists skipping equal item pairs, and then the comparison outcome is determined by comparing the first pair of unequal items. If the item comparison is expensive, it makes sense to want to compare each pair of items at most once, using cmp(). --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4