Ville Vainio wrote:
"Daniel" == Daniel Dittmar <[EMAIL PROTECTED]> 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.

You could write a string wrapper that changes comparison and hashing. I'm not sure that this (+ 1 (Python object + instance dictionary)) would use less memory than the other proposal (+ 1 Tuple + 1 String).


Daniel

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to