3 ms·
I find {} much more readable then dict() because the former is more common. On the other hand list(L) more readable than L[:] because the fact that slicing cop
by mgraczyk 3y ago
I find {} much more readable then dict() because the former is more common.
On the other hand list(L) more readable than L[:] because the fact that slicing copies is more obscure, and these are not equivalent when L is not a list.
My take would be to ignore performance and generally do what is more commonly done.
- nephanth 3y agoMy problem with {} is that the syntax for dicts {x1:y1, x2:y2 ...} and sets {x1, x2 ...} Are very close, and {} is slightly ambiguous. I've run into bugs because i wrote {} for the empty set. Since then i write dict() and set()
- xarope 3y ago+1. I've run into this too, and ended up using set() to clarify.
- dr_kiszonka 3y agoYou could write, e.g., `flags: set = {}` to get both speed and readability.