set.issuperset()

set.issuperset(other)
Returns: bool · Updated March 15, 2026 · Set Methods
sets methods comparison

The .issuperset() method returns True if a set contains all elements of another set — that is, if the other set is a subset of this set. It’s the inverse of .issubset() and useful for checking hierarchical or containment relationships between collections.

Syntax

set.issuperset(other)

Parameters

ParameterTypeDefaultDescription
otheriterableAny iterable to check against. Converted to a set internally.

Returns

  • bool: True if the set contains all elements of other, False otherwise.

Examples

Basic usage

Check if one set contains another:

all_fruits = {"apple", "banana", "cherry", "orange", "mango"}
citrus_fruits = {"orange", "mango"}

print(all_fruits.issuperset(citrus_fruits))
# True

The all_fruits set contains every element in citrus_fruits.

When a set is not a superset

If even one element is missing, .issuperset() returns False:

primary_colors = {"red", "blue", "yellow"}
warm_colors = {"red", "orange", "yellow"}

print(primary_colors.issuperset(warm_colors))
# False

primary_colors doesn’t contain "orange", so it’s not a superset.

With lists

You can check against any iterable:

vowels = {"a", "e", "i", "o", "u"}
input_chars = ["a", "e", "i"]

print(vowels.issuperset(input_chars))
# True

The method converts the list to a set internally for comparison.

Empty sets

An empty set is a subset of every set, which means every set is a superset of an empty set:

any_set = {"anything"}
empty = set()

print(any_set.issuperset(empty))
# True

This is always true because an empty set has no elements that could be missing.

Identical sets

If both sets contain the same elements, each is both a subset and a superset of the other:

a = {1, 2, 3}
b = {1, 2, 3}

print(a.issuperset(b))
# True
print(b.issuperset(a))
# True

Common Patterns

Permission checking

A common use case is checking if a role has all required permissions:

admin_permissions = {"read", "write", "delete", "admin", "manage_users"}
user_permissions = {"read", "write"}

def has_full_access(user_perms, required_perms):
    return user_perms.issuperset(required_perms)

print(has_full_access(user_permissions, {"read"}))
# True
print(has_full_access(user_permissions, {"read", "admin"}))
# False

Feature detection

Check if an environment supports all required features:

required_features = {"ssl", "compression", "auth"}
available_features = {"ssl", "compression", "auth", "caching", "load_balancing"}

if available_features.issuperset(required_features):
    print("Environment is ready for deployment")
else:
    missing = required_features - available_features
    print(f"Missing features: {missing}")
# Environment is ready for deployment

Category validation

Validate that a broader category includes specific items:

programming_languages = {"python", "java", "javascript", "go", "rust"}
compiled_langs = {"java", "go", "rust"}

def is_complete_category(broad, specific):
    return broad.issuperset(specific)

print(is_complete_category(programming_languages, compiled_langs))
# True

Using the >= operator

Python also supports the >= operator as an alternative syntax:

parent = {1, 2, 3, 4, 5}
child = {2, 3, 4}

print(parent >= child)
# True

# Equivalent to:
print(parent.issuperset(child))
# True

This can make code more readable in certain contexts.

Performance

The .issuperset() method has:

  • Average case: O(len(other)) — checking if all elements of other exist in the set
  • Worst case: O(len(self) + len(other)) depending on implementation

Python’s implementation is efficient, especially when the other set is small compared to the set being checked.

See Also