-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into cacheduncached
- Loading branch information
Showing
6 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ omit = | |
*/.tox/* | ||
tests/* | ||
prepare/* | ||
*/_itertools.py | ||
|
||
[report] | ||
show_missing = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from itertools import filterfalse | ||
|
||
|
||
def unique_everseen(iterable, key=None): | ||
"List unique elements, preserving order. Remember all elements ever seen." | ||
# unique_everseen('AAAABBBCCDAABBB') --> A B C D | ||
# unique_everseen('ABBCcAD', str.lower) --> A B C D | ||
seen = set() | ||
seen_add = seen.add | ||
if key is None: | ||
for element in filterfalse(seen.__contains__, iterable): | ||
seen_add(element) | ||
yield element | ||
else: | ||
for element in iterable: | ||
k = key(element) | ||
if k not in seen: | ||
seen_add(k) | ||
yield element |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters