From 614691a7e7683730a8032e0234b62e6e5fb61771 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Fri, 15 Dec 2023 00:34:00 +0100 Subject: [PATCH] [3.12] Optimize unique_justseen() recipe for a common case. (gh-113147) (gh-113150) --- Doc/library/itertools.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index d79f40cd05e8..15b449d65051 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -1016,6 +1016,8 @@ which incur interpreter overhead. "List unique elements, preserving order. Remember only the element just seen." # unique_justseen('AAAABBBCCDAABBB') --> A B C D A B # unique_justseen('ABBcCAD', str.lower) --> A B c A D + if key is None: + return map(operator.itemgetter(0), groupby(iterable)) return map(next, map(operator.itemgetter(1), groupby(iterable, key))) -- 2.47.3