3 ms·
You're right. If a more efficient but unordered dict were to come out, it would have to be in an import and have less comfortable syntax, since the base dict ha
by arijun 6y ago
You're right. If a more efficient but unordered dict were to come out, it would have to be in an import and have less comfortable syntax, since the base dict has a requirement for preserving insert order. But python is not C, and speed is not the most important consideration. Python often goes for "efficient enough, and very comfortable to use", for example by using lists as its ordered flat container instead of arrays. I think that making dicts ordered is another step in the right direction for Python.
- cb321 6y agoWhat Python calls "list" other languages call "array" (or "vector" or "seq" or "dynarray" or ...). So, it is not at all "instead of arrays" as you said, but rather "arrays by another name". People usually say "linked list" or "singly linked list" or "doubly linked list" to refer to the idea/data structure that does pointer hopping during traversal.
- arijun 6y agoMost languages don’t have dynamically resizing arrays, so IMHO vec is a better fit. But my point wasn’t about the name. It was that if you don’t want to incur the costs associated with automatic resizing or with the indirection in python lists (as they are built as arrays of pointers), you have to use a different, less convenient library, like array or numpy. And that’s ok, considering the language goals.