Question: Is there any efficient shortcut method to delete more than one key at a time from a python dictionary?

For instance;

```
x = {'a': 5, 'b': 2, 'c': 3}
x.pop('a', 'b')
print x
{'c': 3}

```

Answer: 
Use [the `del` statement](http://docs.python.org/tutorial/datastructures.html#the-del-statement):

```
x = {'a': 5, 'b': 2, 'c': 3}
del x['a'], x['b']
print x
{'c': 3}

```
Remove a number of keys
=======================

I have tested the performance of three methods:

```py
d = dict.fromkeys('abcdefghijklmnopqrstuvwxyz')
remove_keys = set('abcdef')

# Method 1
for key in remove_keys:
    del d[key]

# Method 2
for key in remove_keys:
    d.pop(key)

# Method 3
{key: v for key, v in d.items() if key no in remove_keys}

```

Here are the results of 1M iterations:

1. 1.88s 1.9 ns/iter (100%)
2. 2.41s 2.4 ns/iter (128%)
3. 4.15s 4.2 ns/iter (221%)

So `del` is the fastest.

Remove a number of keys safely
==============================

However, if you want to delete *safely*, so that it does not fail with KeyError, you have to modify the code:

```py
# Method 1
for key in remove_keys:
    if key in d:
        del d[key]

# Method 2
for key in remove_keys:
    d.pop(key, None)

# Method 3
{key: v for key, v in d.items() if key no in remove_keys}

```

1. 2.03s 2.0 ns/iter (100%)
2. 2.38s 2.4 ns/iter (117%)
3. 4.11s 4.1 ns/iter (202%)

Still, `del` is the fastest.