Interface of the set classes
Pierre Barbier de Reuille
pierre.barbier at cirad.fr
Fri Oct 29 09:32:46 EDT 2004
Ok, I first want to stress that I looked through the newsgroups archives
(on Google) for an answer to my question, but I didn't find it.
It's about the interface of the set classes as defined in the PEP 218.
I don't understand why the sets has an interface of mapping object
without associated value and not an interface of sequence ?
For me, sets are first sequences. I use set where lists are inefficient
or inadapted, for example when I need to remove redundancy and that I
don't care about the positions of my elements. So I happen to switch
from list to sets depending of the data involved (for example if the
data are non-redundant, lists can be more efficient, but if they are,
they become too expensive). And that's just impossible to do with Python
sets ...
Then, why can't you at all access sets element by position ? As Python
iterator are so poor (mainly, you cannot copy them ...) you have things
you cannot do without positionnal iteration (typically when you need to
store the current position and go on the iteration to restart from the
saved position later on).
Please, if this discussion already exists give me the pointer ... and
don't tell me "because of implementation if over dictionnary" ... I
don't think that can be a good answer :o)
Thanks,
Pierre Barbier de Reuille
More information about the Python-list
mailing list