From: Benjamin Peterson Date: Tue, 27 Jan 2009 03:07:53 +0000 (+0000) Subject: excellent place to use a set() #5069 X-Git-Tag: v2.7a1~2189 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1763f8adb4d2d7b59fefedff0aa8ed652c4fe8d2;p=python excellent place to use a set() #5069 --- diff --git a/Lib/posixpath.py b/Lib/posixpath.py index 9fa53d0062..6eb45fd0ea 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -369,12 +369,12 @@ def _resolve_link(path): until we either arrive at something that isn't a symlink, or encounter a path we've seen before (meaning that there's a loop). """ - paths_seen = [] + paths_seen = set() while islink(path): if path in paths_seen: # Already seen this path, so we must have a symlink loop return None - paths_seen.append(path) + paths_seen.add(path) # Resolve where the link points to resolved = os.readlink(path) if not isabs(resolved):