Skip Montanaro writes: > Also, for many situations, "if value in dict" will be extraordinarily > inefficient. In "in" semantics are added to dicts, a corollary move will be > to extend this functionality to other non-dict mappings (e.g., file-based > mapping objects like gdbm). Implementing "in" for them would be > excruciatingly slow if the LHS was "value". To not break the rule of least > astonishment when people push large dicts to disk, the only feasible > implementation is "if key in dict". Skip, Performance issues aside, I can see very valid reasons for the x in "x in dict" to be either the key or (key, value) pair. For this reason, I've come to consider "x in dict" a mis-feature, though I once pushed for it as well. It may be easy to explain that x is just the key, but it's not clearly the only reasonably desirable semantic. -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> Corporation for National Research Initiatives
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4