Emile van Sebille wrote:
Mark Tolonen wrote:
[dict(n) for n in set(tuple(n.items()) for n in l1)]

Anyone know if the ordered items for two different dicts where dicta == dictb is guaranteed the same? I know the ordering is unspecified but you can depend on the sequence of keys matching data and I think it'll also match items.

but for all DA's and DB's below, is that true?


Considering how dictionary is implemented, I don't think so. The dictionary is internally implemented as a hash table, and two dictionary with identical items may have different sized hash table, the algorithm guarantees efficient usage of memory (it resizes when it's too small or too big). On a resize, the hashes are recalculated and the ordering rescrambled.

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to