MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _apply_unique_strategy

Function _apply_unique_strategy

lib/sqlalchemy/engine/_result_cy.py:696–711  ·  view source on GitHub ↗
(
    rows: Sequence[Any],
    destination: list[Any],
    uniques: set[Any],
    strategy: Callable[[Any], Any] | None,
)

Source from the content-addressed store, hash-verified

694@cython.inline
695@cython.cfunc
696def _apply_unique_strategy(
697 rows: Sequence[Any],
698 destination: list[Any],
699 uniques: set[Any],
700 strategy: Callable[[Any], Any] | None,
701) -> list[Any]:
702 i: cython.Py_ssize_t
703 has_strategy: cython.bint = strategy is not None
704 for i in range(len(rows)):
705 row = rows[i]
706 hashed = strategy(row) if has_strategy else row
707 if hashed in uniques:
708 continue
709 uniques.add(hashed)
710 destination.append(row)
711 return destination

Callers 2

_allrowsMethod · 0.85
manyrowsMethod · 0.85

Calls 2

addMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected