[Python-ideas] set.add(x) slower than if x in set:set.add(x)

Daniel Stutzbach daniel at stutzbachenterprises.com
Mon Sep 14 17:13:32 CEST 2009

On Mon, Sep 14, 2009 at 10:03 AM, Gerald Britton
<gerald.britton at gmail.com>wrote:

> Aha ok, so cheap inserts, not so cheap lookups (especially if not found)


The average case lookup cost for a hash table is O(1), better than most tree
structures which typically have a cost of O(log n).

Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20090914/4d34b663/attachment.html>

More information about the Python-ideas mailing list