[Python-Dev] d.get_key(key) -> key?

Martin v. Loewis martin@v.loewis.de
06 Jun 2002 08:44:30 +0200


"Daniel 'eikeon' Krech" <eikeon@eikeon.com> writes:

> Sorry, seems to me like it was on topic for python-dev seeing as
> python dictionaries do not currently have the functionality I
> desire. 

It sure is possible. You have been essentially asking the question
"How do I get the canonical member of an equivalence class in Python",
for which the canonical answer is "you intern the one member of each
equivalence class". As Barry Scott explains, this is best done with an
interning dictionary.

You are also asking "how do I efficiently implement sets in
Python". This is almost a FAQ, the answer is "if the elements are
hashable, use a dictionary".

Regards,
Martin