Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


What 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).


Where's orderedset, though?


Nowhere 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/1...


You 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.


OrderedDict has existed in python since 2.7, released in 2009.


I 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.


> 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: