[Python-Dev] Retrieve an arbitrary element from a set without removing it
"Martin v. Löwis"
martin at v.loewis.de
Sun Oct 25 19:43:52 CET 2009
> Given Alexander's premise, I agree with your response. But his premise
> is wrong. Python's current builtin set class maps abstract equivalence
> classes to representative members. And this *is* useful. Mapping
> arbitrary members of such classes to representative members, sometimes
> called 'canonical', is a standard problem/goal in math. String interning
> is an application of this idea.
Right. However, this is conceptually a function. In some cases (like
string interning), it is mutable (over time) and finite (at any point in
time). We already have a data type that can perfectly represent mutable
finite funcitons, namely dictionaries. And indeed, interning is
implemented by a dictionary.
What Alexander wants is that the set type also becomes useful for
storing canonical representations. I find that inappropriate, since
dicts already provide the one obvious way to do it.
Regards,
Martin
More information about the Python-Dev
mailing list