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).
d = CiDict([('Hi', 12),('hoho',13)])
d['hi']
12
d.keys()
['Hi','hoho']
Note that 'Hi' preserved the
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).
Store the original key together with the value and use a lowercase key
for lookup.
only a
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).
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
On 01 Apr 2005 15:55:58 +0300, Ville Vainio [EMAIL PROTECTED]
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
[Ville Vainio]
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).
class S(str):
def __hash__(self):
return hash(self.lower())
def
On Fri, 01 Apr 2005 18:52:00 GMT, Raymond Hettinger [EMAIL PROTECTED] wrote:
[Ville Vainio]
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).
class
[Bengt Richter]
I wonder if a dict with a general override hook for hashing all keys would be
useful.
E.g., a dict.__keyhash__ that would take key as arg and default as now
returning key.__hash__()
but that you could override. Seems like this could potentially be more
efficient than key
On Fri, 01 Apr 2005 23:04:42 GMT, Raymond Hettinger [EMAIL PROTECTED] wrote:
[Bengt Richter]
I wonder if a dict with a general override hook for hashing all keys would be
useful.
E.g., a dict.__keyhash__ that would take key as arg and default as now
returning key.__hash__()
but that you could
Taken together, these six attributes/methods could cover many wished for
features for the 10% of the cases where a regular dictionary doesn't provide
the
best solution.
You think as much as 10% ?
Rounded up from 9.6 ;-)
More important than the percentage is the clarity of the resulting code
Raymond Hettinger [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
More important than the percentage is the clarity of the resulting code
and the
avoidance of continous reinvention of workarounds.
Separating tool features into a basic and an advanced version is common
solution
11 matches
Mail list logo