[Python] Speed up this code?

Bob Miller kbob at jogger-egg.com
Thu May 25 21:55:28 PDT 2006


Martin Kelly wrote:

> What is the purpose of sets? I didn't know about them yet.

A set is an unordered collection with no duplicates, similar to a
mathematical set.  Sets are a newish part of Python.  They appeared as
a library in Python 2.3, and moved into the language core in 2.4.

Sets happen to be implemented as hash tables, the same a dictionaries.
The difference is that sets don't have values, just keys.  Hash table
lookup is a fast operation, unlike searching a list.

-- 
Bob Miller                              K<bob>
                                        kbob at jogger-egg.com


More information about the Python mailing list