# pydoc > builtins.frozenset

---
type: CommandReference
command: frozenset
mode: pydoc
section: ''
source: pydoc3
---

## Quick Reference

- `frozenset()` — create empty frozenset
- `frozenset(iterable)` — create frozenset from any iterable
- `s.union(t)` — all elements in s or t
- `s.intersection(t)` — elements in both s and t
- `s.difference(t)` — elements in s but not t
- `s.symmetric_difference(t)` — elements in exactly one of s or t
- `s.issubset(t)` — True if s is subset of t
- `s.copy()` — shallow copy

## Name

Build an immutable unordered collection of unique elements.

## Synopsis

frozenset()
frozenset(iterable)
## Options

### Constructor
- `frozenset()` — empty frozenset
- `frozenset(iterable)` — frozenset from iterable

### Set operations (return new frozenset)
- `copy()` — shallow copy
- `difference(*others)` — elements in this set not in others
- `intersection(*others)` — elements common to this set and all others
- `symmetric_difference(other)` — elements in exactly one of the two sets
- `union(*others)` — all elements from this set and all others
- `__and__(self, value)` — `self & value`
- `__or__(self, value)` — `self | value`
- `__sub__(self, value)` — `self - value`
- `__xor__(self, value)` — `self ^ value`
- `__rand__`, `__ror__`, `__rsub__`, `__rxor__` — reflected operators (`value & self`, etc.)

### Comparison and membership
- `isdisjoint(other)` — True if sets have no common elements
- `issubset(other)` — True if all elements of this set are in other
- `issuperset(other)` — True if this set contains all elements of other
- `__contains__(x)` — `x in s`
- `__eq__`, `__ne__`, `__lt__`, `__le__`, `__gt__`, `__ge__` — comparison operators

### Hashing, iteration, size
- `__hash__()` — hash value (frozensets are hashable)
- `__iter__()` — iterator over elements
- `__len__()` — number of elements
- `__repr__()` — representation string

### Pickling and memory
- `__reduce__()` — state information for pickling
- `__sizeof__()` — size in bytes

### Class and static methods
- `__class_getitem__(item)` — support for PEP 585 (generic types)
- `__new__(*args, **kwargs)` — create new object

## Examples

python
>>> frozenset()
frozenset()

>>> frozenset([1, 2, 3, 2])
frozenset({1, 2, 3})

>>> a = frozenset([1,2,3])
>>> b = frozenset([3,4,5])
>>> a.union(b)
frozenset({1, 2, 3, 4, 5})
>>> a.intersection(b)
frozenset({3})
>>> a.difference(b)
frozenset({1, 2})
>>> a.symmetric_difference(b)
frozenset({1, 2, 4, 5})
>>> a.issubset(b)
False
>>> a.copy()
frozenset({1, 2, 3})
## See Also

- `set` — mutable counterpart
- `tuple` — another immutable collection
- `list` — mutable sequence
- `frozenset` — Python documentation