Live data from Hacker News

A “frozen” dictionary for Python

lwn.net

171–172 of 172 posts

Re: A “frozen” dictionary for Python

#171

Earlier quoted context omitted.

Python's decision to make dict keys ordered in the spec was a mistake. It may be the best implementation so far, but it eliminates potential improvements in the future.

Agreed. The only reason to make them sorted is because people would wrongly assume that they where. You can argue that a programming language should not have unexpected behaviors, and apparently unsorted dictionary keys where a surprise to many, on the other hand I feel like it's a failure of education. The problem was that assuming that keys would be sorted was frequently true, but not guaranteed. An alternative sol…

"sorted" and "ordered" mean very different things in this context.

And the reason we have ordered dict keys now is because it's trivial with the new compact structure (the actual hash table contains indices to an auxiliary array, which can just be appended to with every insertion). It has nothing to do with any randomization of the hashing process.

Re: A “frozen” dictionary for Python

#172
post #20

I wonder whether Raymond Hettinger has an opinion on this PEP. A long time ago, he wrote: "freezing dicts is a can of worms and not especially useful". https://mail.python.org/pipermail/python-dev/2006-February/0...

Ha, Raymond Hettinger has a lot of opinions. Great guy and I admire his dedication to Python, but in my own experience (and the experience of some other contributors), he has a chilling effect on contributions to certain parts of the CPython code base.

Not that it's entirely unwarranted, of course.

Post reply on HN