[Tutor] set and sets.Set

Steven D'Aprano steve at pearwood.info
Wed Apr 21 23:14:12 CEST 2010


On Thu, 22 Apr 2010 02:28:03 am Bala subramanian wrote:
> Friends,
> Someone please write me the difference between creating set with
> set() and a sets.Set().

The sets module, including sets.Set(), were first introduced in Python 
2.3 and is written in Python.

The built-in set object was introduced in Python 2.4 and is re-written 
in C for speed.

Functionally, they are identical. Speed-wise, the built-in version is 
much faster, so unless you need to support Python 2.3, always use the 
built-in set type.



-- 
Steven D'Aprano


More information about the Tutor mailing list