3 ms·
The dictionary implementation of Python is a hash table using open addressing with quadratic probing. Deletion is essentially a lookup to replace the key with a
by alxv 17y ago
The dictionary implementation of Python is a hash table using open addressing with quadratic probing. Deletion is essentially a lookup to replace the key with a tombstone. And, the table is never resized after a deletion.
So yes, the whole operation is O(1) on average.