• Tim Peters's avatar
    Speed tuple comparisons in two ways: · d7ed3bf5
    Tim Peters yazdı
    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.
    d7ed3bf5
Adı
Son kayıt (commit)
Son güncelleme
Demo Loading commit data...
Doc Loading commit data...
Grammar Loading commit data...
Include Loading commit data...
Lib Loading commit data...
Mac Loading commit data...
Misc Loading commit data...
Modules Loading commit data...
Objects Loading commit data...
PC Loading commit data...
PCbuild Loading commit data...
Parser Loading commit data...
Python Loading commit data...
RISCOS Loading commit data...
Tools Loading commit data...
.cvsignore Loading commit data...
.hgtags Loading commit data...
LICENSE Loading commit data...
Makefile.pre.in Loading commit data...
README Loading commit data...
acconfig.h Loading commit data...
config.h.in Loading commit data...
configure Loading commit data...
configure.in Loading commit data...
install-sh Loading commit data...
setup.py Loading commit data...