summaryrefslogtreecommitdiff
path: root/Lib/codecs.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-05-15 20:12:59 +0000
committerTim Peters <tim.peters@gmail.com>2001-05-15 20:12:59 +0000
commitd7ed3bf5524f68860536e330e2a5b1cc50c10f77 (patch)
tree18735acd5afb38a5435cca47bf764fbe2b50b4cc /Lib/codecs.py
parentfab96cc2ffd2834a0c2e6c10f5649740e87b6214 (diff)
downloadcpython-git-d7ed3bf5524f68860536e330e2a5b1cc50c10f77.tar.gz
Speed tuple comparisons in two ways:
1. Omit the early-out EQ/NE "lengths different?" test. Was unable to find any real code where it triggered, but it always costs. The same is not true of list richcmps, where different-size lists appeared to get compared about half the time. 2. Because tuples are immutable, there's no need to refetch the lengths of both tuples from memory again on each loop trip. BUG ALERT: The tuple (and list) richcmp algorithm is arguably wrong, because it won't believe there's any difference unless Py_EQ returns false for some corresponding elements: >>> class C: ... def __lt__(x, y): return 1 ... __eq__ = __lt__ ... >>> C() < C() 1 >>> (C(),) < (C(),) 0 >>> That doesn't make sense -- provided you believe the defn. of C makes sense.
Diffstat (limited to 'Lib/codecs.py')
0 files changed, 0 insertions, 0 deletions