Hash map with multiple keys per value ?

Alex Martelli aleax at mail.comcast.net
Sun Nov 13 03:26:08 CET 2005

Chris Stiles <b9a9-3arx at spamex.com> wrote:
> > alias insertion just be of the form "x aliases to y" rather than "x
> > names object XXX"?
> In this case, strictly speaking there are no such thing as an 'object XXX',
> all the aliases are names for the object, each as important as each other.

Fine, but, quite apart from names, IS there a Python object with a given
identity, of which these aliases are names of?  Or is that "object"
something which does NOT exist as a Python object (in which case maybe
calling it an "entity", or some other name that's not used for specific
purposes in Python, might be clearer!)...?

> >   def alias(self, x, y):
> >      dx = self.d.get(x,set([x]))
> >      dy = self.d.get(y,set([y]))
> >      self.d[x]=self.d[y]=dx+dy
>        ^^^^^^^^^^^^^^^^^^^^^^^^^
> Will that end up with two(many) references to the same set? [Though in any
> case I would be iterating over all values in the set).

Yes, but it's buggy (doesn't modify the self.d[z] entries for all the
z's which aren't either x nor y but alias either of them).


More information about the Python-list mailing list