Check if dictionary empty with == {}

MRAB python at
Thu Aug 20 01:33:49 CEST 2015

On 2015-08-20 00:15, Skip Montanaro wrote:
> Comparison against {} will be less efficient. You need to create a
> dictionary every time instead of just checking the length of your
> dictionary, which is likely stored in the header. So, it will work, but
> certainly isn't idiomatic Python.
Well, that depends on the intention.

Is it checking whether the dictionary is empty, or whether it's an
empty dictionary (and not, say, an empty list)?

More information about the Python-list mailing list