'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
ob.__delitem__(sub)
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'.
tjr
More information about the Python-list
mailing list