core: add helper for more_iterable to check that all types involved are hashable

Otherwise unique_everseen performance may degrade to quadratic rather than linear

For now hidden behind HPI_CHECK_UNIQUE_EVERSEEN flag

also switch some modules to use it
This commit is contained in:
karlicoss 2023-10-31 00:42:17 +00:00
parent d6786084ca
commit 0354f53579
8 changed files with 90 additions and 23 deletions

View file

@ -9,9 +9,8 @@ from pathlib import Path
import sqlite3
from typing import Sequence, Iterator, Optional
from more_itertools import unique_everseen
from my.core import get_files, Paths, datetime_aware, Res, make_logger, make_config
from my.core.common import unique_everseen
from my.core.error import echain, notnone
from my.core.sqlite import sqlite_connection
import my.config
@ -202,4 +201,4 @@ def _messages() -> Iterator[Res[Message]]:
def messages() -> Iterator[Res[Message]]:
yield from unique_everseen(_messages())
yield from unique_everseen(_messages)