5.14.4 Comparison to the built-in set types
The built-in set and frozenset types were designed based
on lessons learned from the sets module. The key differences are:
- Set and ImmutableSet were renamed to set and
frozenset.
- There is no equivalent to BaseSet. Instead, use
isinstance(x, (set, frozenset))
.
- The hash algorithm for the built-ins performs significantly better
(fewer collisions) for most datasets.
- The built-in versions have more space efficient pickles.
- The built-in versions do not have a union_update() method.
Instead, use the update() method which is equivalent.
- The built-in versions do not have a _repr(sorted=True) method.
Instead, use the built-in repr() and sorted()
functions:
repr(sorted(s))
.
- The built-in version does not have a protocol for automatic conversion
to immutable. Many found this feature to be confusing and no one
in the community reported having found real uses for it.
Release 2.5a0, documentation updated on August 30, 2005.
See About this document... for information on suggesting changes.