Case-insensitive dict, non-destructive, fast, anyone?

Ville Vainio ville at spammers.com
Fri Apr 1 07:55:58 EST 2005


>>>>> "Daniel" == Daniel Dittmar <daniel.dittmar at sap.corp> writes:

    Daniel> Ville Vainio wrote:

    >> I need a dict (well, it would be optimal anyway) class that
    >> stores the keys as strings without coercing the case to upper
    >> or lower, but still provides fast lookup (i.e. uses hash
    >> table).

    Daniel> Store the original key together with the value and use a
    Daniel> lowercase key for lookup.

That's what I thought initially, but the strings take most of the
space in dict and I didn't feel like doubling the size.

It would be the "simplest thing that could possibly work", though.

-- 
Ville Vainio   http://tinyurl.com/2prnb



More information about the Python-list mailing list