get original key set from defaultdict

You have to exclude. the keys that has the default value!

>>> [i for i in d if d[i]!=d.default_factory()]
['key2', 'key1']

Time comparison with method suggested by Jean,

>>> def funct(a=None,b=None,c=None):
...     s=time.time()
...     eval(a)
...     print time.time()-s
...
>>> funct("[i for i in d if d[i]!=d.default_factory()]")
9.29832458496e-05
>>> funct("[k for k,v in d.items() if v!=d.default_factory()]")
0.000100135803223
>>> ###storing the default value to a variable and using the same in the list comprehension reduces the time to a certain extent!
>>> defa=d.default_factory()
>>> funct("[i for i in d if d[i]!=defa]")
8.82148742676e-05
>>> funct("[k for k,v in d.items() if v!=defa]")
9.79900360107e-05