[Python-ideas] Add dict.getkey() and set.get()

Serhiy Storchaka storchaka at gmail.com
Sat Sep 14 22:10:35 CEST 2013

14.09.13 19:19, Victor Stinner написав(ла):
> What is the use case of such methods? Why not using dict.kets() and
> tuple(set)?

Scanning dict.keys() or set has linear complexity. dict.getkey() and 
set.get() can be easily implemented with O(1).

I have no good use cases. Perhaps every problem which requires 
dict.getkey() or set.get() can be solved with additional synchronized 
dict which maps key to key. This is also true for TransformDict.

More information about the Python-ideas mailing list