John Nagle <nagle at animats.com> writes: > What's the cheapest way to test for an empty dictionary in Python? > > if len(dict.keys() > 0) : I like to think len(dict) is constant time but I haven't checked the code. Same for bool(dict) (which is what you get when you run "if dict: ...").