• Tim Peters's avatar
    Changed the dict implementation to take "string shortcuts" only when · 0ab085c4
    Tim Peters yazdı
    keys are true strings -- no subclasses need apply.  This may be debatable.
    
    The problem is that a str subclass may very well want to override __eq__
    and/or __hash__ (see the new example of case-insensitive strings in
    test_descr), but go-fast shortcuts for strings are ubiquitous in our dicts
    (and subclass overrides aren't even looked for then).  Another go-fast
    reason for the change is that PyCheck_StringExact() is a quicker test
    than PyCheck_String(), and we make such a test on virtually every access
    to every dict.
    
    OTOH, a str subclass may also be perfectly happy using the base str eq
    and hash, and this change slows them a lot.  But those cases are still
    hypothetical, while Python's own reliance on true-string dicts is not.
    0ab085c4
dictobject.c 48 KB