delete_duplicates

delete_duplicates(iterable, key=None, hashable=None, cache=None): 

LLM Docstring

Yield the first item associated with each distinct key.

The function uses a set by default and automatically falls back to a list when adding an unhashable key raises TypeError. A supplied cache is updated in place and can preserve uniqueness state across calls.

  • iterable: collections.abc.Iterable

    Values to filter.

  • key: callable | None

    Optional function producing the value used for duplicate detection.

  • hashable: bool | None

    Force set-based or list-based storage; None enables automatic fallback.

  • cache: set | list | None

    Existing membership cache to update.

  • :returns: collections.abc.Iterator

    Iterator yielding only the first value for each key.


Feedback

Examples

Templates

Documentation