3 ms·
I've written a lot of Python, but more Java. This is where I have a gripe with "batteries included." In Java, I'd have to think slightly about this, then use a
by dehrmann 7y ago
I've written a lot of Python, but more Java. This is where I have a gripe with "batteries included." In Java, I'd have to think slightly about this, then use a LinkedHashMap. It's been in Java since *2002. It also has a Set flavor. Python just doesn't have as rich of a collection of included data structures, and the APIs are more limited.
- masklinn 7y agoWhat java calls linkedhashmap, Python calls ordereddict. It's not quite as old as java's linkedhashmap but is no spring chicken either (it's a bit above 10 years old).
- dehrmann 7y agoWhere's orderedset, though?
- masklinn 7y agoNowhere because so far the core team has remained unconvinced. People have brought up replacing standard set implementation by a variant of dict's (even expressing surprise that that wasn't already the case) but no dice yet. There are discussions on the subject on python-dev once in a while e.g. https://mail.python.org/pipermail/python-dev/2019-February/156466.html https://mail.python.org/pipermail/python-dev/2019-February/1...
- TylerE 7y agoOrderedDict has existed in python since 2.7, released in 2009.
- Igelau 7y agoI agree, and I think it's troublesome that dict now means something more specialized than it did before and the language doesn't communicate this. The dict is dead, long live the dict. I suspect it's the result of my Java goggles, because the distaste comes from a sense that this is analagous to if the Map interface suddenly always meant LinkedHashMap.
- oefrha 7y ago> The dict is dead, long live the dict. That’s like saying binary search tree is dead because the implementation uses a red-black tree.
- zo1 7y agoYou call that a failing, and others call that a feature. I love the fact that I haven't had to think about ridiculous nit-pick level data-structure trade offs. In python you have a very basic set of data structures, and short of doing something ridiculously novel or exotic, that's all you need. It's part of the beauty of the language.