3 ms·
Practically, what your wish would accomplish ? Will it make most people more productive ? Produce less bug ? Learn faster ? Most Python coders don't even use s
by sametmax 8y ago
Practically, what your wish would accomplish ? Will it make most people more productive ? Produce less bug ? Learn faster ?
Most Python coders don't even use sets more than once a year. Hell, I use collections.deque more than sets.
But dicts ? We use it all the time. In fact, failing a {} + {} is a recurring disapointment in all my classrooms.
Plus, in PHP and JS, arrays/objects are the "do-it-all" data structure. And it's horrible. You see the same data structure everywhere. You have to read in details what something is, and what it's for.
It very nice that dict and set are very distincts, and that they have a distint set of operators. This way it's super easy to scan the code and know what the data structure is, and what it's used for. That's why I always teach set([1, 2]) and not {1, 2} first. It helps people to make a clear distinction in their mind.
- zimablue 8y agoI use sets a lot, sample size of one. I do data science/engineering stuff, sets of columns/sets of keys. I'm very sceptical of your claim that most developers don't use sets.
- sametmax 8y agoActually, a lot of Python users don't even know sets exist. Or they forgot, and use them randomly after they google "remove duplicates". Even among the sets users, a lot of them don't even know you can use ^, | and ~ with them. Size sample: a few hundred students and colleagues over 15 years. It make sense: for columns, it's quite commonto use dicts, or pandas dataframe. The sets of key is just the dict keys memory view. A web dev rarely needs sets. A GUI coders, a sysadmin or a geograph neither. It's not that sets are not useful, it's just that in the huge numbers of things you need to do in programming, accross all fields that Python attends to, they are pretty niche.
- rocqua 8y ago> It very nice that dict and set are very distincts, and that they have a distint set of operators. This way it's super easy to scan the code and know what the data structure is, and what it's used for. This is exactly why I want explicit typing in Python.
- sametmax 8y agoYou do with type annotations. But type declaration may not be in the view port. Or you may read a script or snippet, which is a type or code that won't bother with typing.
- klibertp 8y ago> But type declaration may not be in the view port. Type declaration doesn't have to be in the view; the very point of type annotations is to support static type systems, which you can query about any type. For example, if you use mypy, you can add `reveal_type( any_kind_of_expr )` anywhere in your code and you'll get the most precise type available, be it inferred or declared manually, for that expression at given point in code.