Just to clarify your python 2 note: In python 3 keys() returns an iterator, so there is no penalty (i.e. iterkeys was dropped, keys assumed iterkeys interface).<p>The equivalent python2 behaviour can be obtained using list(somedict.keys())