From 05079d93e410fca1e41ed32e67c54d63cbd9b35b Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Fri, 29 Sep 2023 09:28:01 +0200 Subject: [PATCH] gh-109868: Skip deepcopy memo check for empty memo (GH-109869) --- Lib/copy.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/copy.py b/Lib/copy.py index 6d7bb9a111b..a69bc4e78c2 100644 --- a/Lib/copy.py +++ b/Lib/copy.py @@ -121,13 +121,13 @@ def deepcopy(x, memo=None, _nil=[]): See the module's __doc__ string for more info. """ + d = id(x) if memo is None: memo = {} - - d = id(x) - y = memo.get(d, _nil) - if y is not _nil: - return y + else: + y = memo.get(d, _nil) + if y is not _nil: + return y cls = type(x)