[Python-Dev] Re: PEP 218 (sets); moving set.py to Lib
Guido van Rossum
Mon, 19 Aug 2002 11:25:38 -0400
> > [François]
> > > [...] why the sorting/non-sorting virtues of `repr' should be tied
> > > with the constructor. [...]
> > If dicts can survive being rendered unsorted, then so can Sets. Maybe I
> > should remove the sort_repr argument altogether; it's easy enough for
> > the test suite to use some other trick.
> I presume you already have a solution when testing dicts?
These tests just require an equality test between the actual outcome
and the expected outcome. Since sets support equality testing,
there's no reason not to use that. (I guess the original test was
being paranoid, or was written before __eq__ was implemented.)
> > But for now, I'll just leave sort_repr=False in.
> As long as users do not discover it, they will not use it! :-)
We can mull that over until the first beta release.
> By the way (this was discussed on Python list a while ago), it might
> be worth stressing in the official documentation that dicts, and maybe
> Sets as well, all have a "natural" iteration order which remains fixed at
> least while the dict or Set does not loose or acquire keys, and that this
> same fixed order is used for .items(), .keys(), .values(), and all three
> .iter* flavours. It is sometimes useful being able to rely on this fact,
> especially if Python clearly commits itself through the documentation.
AFAIK that's well documented.
--Guido van Rossum (home page: http://www.python.org/~guido/)