How about the simple:

for e in ['cc', 'dd',...]: 
  a.pop(e)
Answer from Himadri Choudhury on Stack Overflow
🌐
DigitalOcean
digitalocean.com › community › tutorials › pop-python
How to Use `.pop()` in Python Lists and Dictionaries | DigitalOcean
July 24, 2025 - Python’s .pop() method is a powerful and flexible built-in function that allows you to remove and return elements from both lists and dictionaries. This method is especially useful in scenarios where you need to both extract and delete items in a single, efficient operation.
🌐
W3Schools
w3schools.com › python › ref_dictionary_pop.asp
Python Dictionary pop() Method
Python Examples Python Compiler ... 1964 } car.pop("model") print(car) Try it Yourself » · The pop() method removes the specified item from the dictionary....
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-remove-multiple-keys-from-dictionary
Python - Remove Multiple Keys from Dictionary - GeeksforGeeks
July 12, 2025 - This method is efficient as it ... we can remove multiple keys from dictionary. ... We can use the pop() method to remove keys from the dictionary one by one in a loop....
🌐
GeeksforGeeks
geeksforgeeks.org › python-dictionary-pop-method
Python Dictionary pop() Method - GeeksforGeeks
May 9, 2025 - Explanation: while loop repeatedly ... pair from the dictionary using pop() until the dictionary is empty. ... Python dictionary methods is collection of Python functions that operates on Dictionary.Python Dictionary is like a map that is used ...
🌐
Codefinity
codefinity.com › courses › v2 › 102a5c09-d0fd-4d74-b116-a7f25cb8d9fe › 972d480a-794b-4a56-9980-e8fa636afef4 › 1577d83c-c037-4776-9fb1-ba4b13baa3d4
Learn Deleting Elements with Return Values | Mastering Python Dictionaries
The pop() method in Python dictionaries allows you to remove a key-value pair based on its key and returns the corresponding value. This method is particularly useful when you need to extract and process a value while simultaneously removing ...
🌐
Note.nkmk.me
note.nkmk.me › home › python
Remove an Item from a Dictionary in Python: pop, popitem, clear, del | note.nkmk.me
April 27, 2025 - In Python, you can remove an item (key-value pair) from a dictionary (dict) using the pop(), popitem(), clear() methods, or the del statement. You can also remove items based on specific conditions us ...
🌐
Programiz
programiz.com › python-programming › methods › dictionary › pop
Python Dictionary pop()
Python Dictionary fromkeys() Python ... Dictionary update() Python Dictionary clear() Python Dictionary get() The pop() method removes and returns an element from a dictionary having the given key....
🌐
Finxter
blog.finxter.com › home › learn python blog › how to remove multiple keys from a python dictionary
How to Remove Multiple Keys from a Python Dictionary - Be on the Right Side of Change
September 14, 2022 - Summary: You can use one of these methods to delete multiple keys from a dictionary Python – (1) Iterate across the list of keys to be deleted and use the syntax del dict[‘key’] (2) Iterate across the list of keys to be deleted and call the dictionary.pop(key)method.
Find elsewhere
🌐
Vultr Docs
docs.vultr.com › python › standard-library › dict › pop
Python dict pop() - Remove Key-Value Pair | Vultr Docs
November 7, 2024 - The pop() method in Python dictionaries is an essential tool for managing key-value pairs. It allows for the removal of a specified key from a dictionary and returns the value associated with that key.
Top answer
1 of 3
19

A simple comprehension inside dict will do:

dict(src.popitem() for _ in range(20000))

Here you have the timing tests

setup = """
src = {i: i ** 3 for i in range(1000000)}

def method_1(d):
  dst = {}
  while len(dst) < 20000:
      item = d.popitem()
      dst[item[0]] = item[1]
  return dst

def method_2(d):
  return dict(d.popitem() for _ in range(20000))
"""
import timeit
print("Method 1: ", timeit.timeit('method_1(src)', setup=setup, number=1))

print("Method 2: ", timeit.timeit('method_2(src)', setup=setup, number=1))

Results:

Method 1:  0.007701821999944514
Method 2:  0.004668198998842854
2 of 3
12

This is a bit faster still:

from itertools import islice
def method_4(d):
    result = dict(islice(d.items(), 20000))
    for k in result: del d[k]
    return result

Compared to other versions, using Netwave's testcase:

Method 1:  0.004459443036466837  # original
Method 2:  0.0034434819826856256 # Netwave
Method 3:  0.002602717955596745  # chepner
Method 4:  0.001974945073015988  # this answer

The extra speedup seems to come from avoiding transitions between C and Python functions. From disassembly we can note that the dict instantiation happens on C side, with only 3 function calls from Python. The loop uses DELETE_SUBSCR opcode instead of needing a function call:

>>> dis.dis(method_4)
  2           0 LOAD_GLOBAL              0 (dict)
              2 LOAD_GLOBAL              1 (islice)
              4 LOAD_FAST                0 (d)
              6 LOAD_ATTR                2 (items)
              8 CALL_FUNCTION            0
             10 LOAD_CONST               1 (20000)
             12 CALL_FUNCTION            2
             14 CALL_FUNCTION            1
             16 STORE_FAST               1 (result)

  3          18 SETUP_LOOP              18 (to 38)
             20 LOAD_FAST                1 (result)
             22 GET_ITER
        >>   24 FOR_ITER                10 (to 36)
             26 STORE_FAST               2 (k)
             28 LOAD_FAST                0 (d)
             30 LOAD_FAST                2 (k)
             32 DELETE_SUBSCR
             34 JUMP_ABSOLUTE           24
        >>   36 POP_BLOCK

  4     >>   38 LOAD_FAST                1 (result)
             40 RETURN_VALUE

Compared with the iterator in method_2:

>>> dis.dis(d.popitem() for _ in range(20000))
  1           0 LOAD_FAST                0 (.0)
        >>    2 FOR_ITER                14 (to 18)
              4 STORE_FAST               1 (_)
              6 LOAD_GLOBAL              0 (d)
              8 LOAD_ATTR                1 (popitem)
             10 CALL_FUNCTION            0
             12 YIELD_VALUE
             14 POP_TOP
             16 JUMP_ABSOLUTE            2
        >>   18 LOAD_CONST               0 (None)
             20 RETURN_VALUE

which needs a Python to C function call for each item.

🌐
Centron
centron.de › startseite › python .pop(): remove and return items from lists and dicts
Python .pop(): Remove and Return Items from Lists and Dicts
May 6, 2026 - Use Python’s .pop() to remove and return items from lists and dictionaries, with clear syntax, defaults, errors, and performance tips.
🌐
DataCamp
datacamp.com › tutorial › python-pop
How to Use the Python pop() Method | DataCamp
July 31, 2024 - The Python Cheat Sheet for Beginners ... Python's syntax and different functions. The pop() method is used in lists and dictionaries to remove specific items and return the value. I will show a quick example for both. The first example shows how to remove an item from a list using ...
🌐
Inspired Python
inspiredpython.com › tip › python-dictionary-tricks-popping-items
Python Dictionary Tricks: Popping items • Inspired Python
>>> d.pop("favorite_language", "Python") 'Python' >>> d['favorite_city'] = "London" >>> d.popitem() ('favorite_city', 'London') “ · You can use the pop(key) method to remove (and return) the value of an item in a dictionary.
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › remove multiple keys from python dictionary
Remove Multiple keys from Python Dictionary - Spark By {Examples}
May 31, 2024 - How to remove multiple keys from Python Dictionary? To remove multiple keys you have to create a list or set with the keys you want to delete from a
🌐
Codecademy
codecademy.com › docs › python › dictionaries › .pop()
Python | Dictionaries | .pop() | Codecademy
May 23, 2022 - The .pop() method of a Python dictionary returns the value of a specified key, then removes the key-value pair from the dictionary.
🌐
freeCodeCamp
freecodecamp.org › news › python-remove-key-from-dictionary
Python Remove Key from Dictionary – How to Delete Keys from a Dict
February 22, 2023 - # initialize a dictionary My_dict = {1: "Red", 2: "Blue", 3: "Green", 4: "Yello", 5: "Black"} # using popitem() Deleted_key = My_dict.popitem() print(Deleted_key) ... As you can see, the function removed the last key:value pair – 5: "Black" – from the dictionary. You can easily delete multiple keys from a dictionary using Python.
🌐
datagy
datagy.io › home › python posts › python: remove key from dictionary (4 different ways)
Python: Remove Key from Dictionary (4 Different Ways) • datagy
December 20, 2022 - Python makes it easy to remove multiple keys from a dictionary. The safest way of doing this is to loop over a list of keys and use the .pop() method.
Top answer
1 of 3
4

You can define yourself dictionary object using python ABCs which provides the infrastructure for defining abstract base classes. And then overload the pop attribute of python dictionary objects based on your need:

from collections import Mapping

class MyDict(Mapping):
    def __init__(self, *args, **kwargs):
        self.update(dict(*args, **kwargs))

    def __setitem__(self, key, item): 
        self.__dict__[key] = item

    def __getitem__(self, key): 
        return self.__dict__[key]

    def __delitem__(self, key): 
        del self.__dict__[key]

    def pop(self, k, d=None):
        return k,self.__dict__.pop(k, d)

    def update(self, *args, **kwargs):
        return self.__dict__.update(*args, **kwargs)

    def __iter__(self):
        return iter(self.__dict__)

    def __len__(self):
        return len(self.__dict__)

    def __repr__(self): 
        return repr(self.__dict__)

Demo:

d=MyDict()

d['a']=1
d['b']=5
d['c']=8

print d
{'a': 1, 'c': 8, 'b': 5}

print d.pop(min(d, key=d.get))
('a', 1)

print d
{'c': 8, 'b': 5}

Note : As @chepner suggested in comment as a better choice you can override popitem, which already returns a key/value pair.

2 of 3
3

A heap supports the pop-min operation you describe. You'll need to create a heap from your dictionary first, though.

import heapq
# Must be two steps; heapify modifies its argument in-place.
# Reversing the key and the value because the value will actually be
# the "key" in the heap. (Or rather, tuples are compared 
# lexicographically, so put the value in the first position.)
heap = [(v, k) for k, v in some_dict.items()]
heapq.heapify(heap)

# Get the smallest item from the heap
value, key = heapq.heappop(heap)