Add Difference Operators To Dict

I’m -1 on dict - dict (because the values in the 2nd dict are ignored). I’m -1 on dict - iterable because it’s a performance trap (key in iterable takes O(n) time, and if the iterable is a set or a dict, you can easily get O(1) with custom code). I’m -1 on dict - set_like because requiring the RHS to be set like feels like an arbitrary restriction.

The problem is that dict - things_to_remove is intended to be the “one obvious way” to do this operation, so making it less intuitive, or less efficient, than the alternatives is a bad choice. And the best approach is highly dependent on the actual objects involved.

Maybe a better design would be to have a method that constructs a new dict by selecting a subset of keys from an existing dict, and then this operation would be d.select(d.keys() - other_dict.keys()). But at that point, you’re so close to {k:d[k] for k in d.keys() - other_dict.keys()} (or simply {k:d[k] for k in d if k not in other_dict}) that it’s hardly worth the effort…