R
Ryan Ginstrom
On Behalf Of John Nagle
I believe that the following is fairly efficient:
for k in D:
return False
return True
True
Regards,
Ryan Ginstrom
What's the cheapest way to test for an empty dictionary in Python?
if len(dict.keys() > 0) :
is expensive for large dictionaries, and makes loops O(N^2).
I believe that the following is fairly efficient:
for k in D:
return False
return True
True
Regards,
Ryan Ginstrom