On Mar 23, 3:53 pm, John Nagle <[EMAIL PROTECTED]> wrote: > 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). > > John Nagle
As others have stated, if <container object>: is false for built-in container types such as dicts, lists, sets, tuples,... Its nice to make any of your owh container types follow the same convention too. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list