docs patch: dicts and sets

Raymond Hettinger python at rcn.com
Sun May 20 05:12:48 EDT 2007


On May 13, 4:52 pm, r... at yahoo.com wrote:
> Dismissing this as not a "real problem" is both wrong
> and offensive to people taking the time to actually
> propose improvements.

I should have elaborated on what I meant by saying that there is not a
real problem.  Another way to put it is that the docs are sufficient
when they say that set ordering is arbitrary.  That should be a cue to
not have *any* expectations about the internal ordering of sets and
dicts.

Any further documentation of behavior would be a mistake because it
would of necessity expose implementation specific details.  For
instance, there is another intentionally undocumented observable
behavior that sets and dicts change their internal order as new
members are added.  It is also intentional that Python makes almost no
promises about the location of objects in memory.  IIRC, the only
guarantees made about object identity are that "a is a" is always true
and None can be tested with "is".


Raymond




More information about the Python-list mailing list