Set is mutable; frozenset is immutable and hashable
Both set and frozenset are unordered collections of unique hashable elements and support the same mathematical set operations. The key difference is mutability: set can add and remove elements, so it is not hashable and cannot be a dict key or another set's element. frozenset is immutable after construction, so it is hashable if its elements are hashable and can be used as a dict key or set member.
Use set when you need to mutate membership during the program.
Use frozenset when you need an immutable, hashable signature, such as a cache key or permission set.
Trade-off: frozenset gives safety and hashability; set gives mutation. You can convert with set(fs) or frozenset(s).
Common mistake: thinking set elements can be any object. Elements must be hashable, so lists and dicts cannot be set members.
Version note: set and frozenset have been built-in since Python 2.4; their core semantics are stable.
0-2 years experience
2-5 years experience
5-8 years experience
8+ years experience