all Python 3Sets (set)function
frozenset.copy
frozenset
For an immutable frozenset, copy() returns the same object (nothing to copy).
Syntax
f.copy()
The method exists for interface parity: code that accepts any set can call copy() without checking whether it got a set or a frozenset. There is nothing to protect from mutation, so no new object is built — you get the original back. When you need a copy you can actually modify, use set(f); copy() will never hand you a mutable one.
Examples
f = frozenset({1, 2})
print(f.copy() is f) # → True
print(f.copy()) # → frozenset({1, 2})
print(frozenset().copy()) # → frozenset()
s = {1, 2}
print(s.copy() is s) # → False
See also
Open in the full glossarydocs.python.orgReport an inaccuracy