Skip to content
Advertisement

Compare dictionaries ignoring specific keys

How can I test if two dictionaries are equal while taking some keys out of consideration. For example,

JavaScript

should return True.

UPD: I’m looking for an efficient, fast solution.

UPD2. I ended up with this code, which appears to be the fastest:

JavaScript

Timings: https://gist.github.com/2651872

Advertisement

Answer

JavaScript

EDIT: This might be faster and more memory-efficient:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement