Carl Banks <pavlovevide...@gmail.com> writes: > Not necessarily: if the hash calculation for x is expensive enough the > get version would still be faster.
Yeah, the get version with the special marker value is just ugly IMO, as is the version with exceptions. Maybe there should be a two-value version: found, value = d.xget(key [,default]) xget returns a 2-tuple, the first element of which is a boolean indicating whether the key was present. The second is the value (if present) or the default (if supplied), or None. Another possible interface: values = d.vget(key) This returns a list containing the values found for the key, or an empty list if none are found. In the case where d is a dict, the list is therefore always either 1-element or empty, but one could imagine other mapping types where longer lists could come back. -- http://mail.python.org/mailman/listinfo/python-list