'del' function for Dictionary

Terry Reedy tjreedy at udel.edu
Fri Jul 17 17:09:40 EDT 2009

mayank gupta wrote:
> Hi all,
> I wanted to know whether there is a more efficient way to delete an 
> entry from a dictionary (instead of using the 'del' function), because 
> after analyzing the time taken by the code, it seems to me that the 
> 'del' function takes most of the time.

That is hard to imagine.

del ob[sub]

has the same effect as


but I suspect this would take longer since it requires a runtime 
attribute lookup and Python level function call.  So I am pretty sure 
the answer is 'no'.


More information about the Python-list mailing list