From 2260fca5203f0a2c21741e696f1db44688a98502 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Mon, 25 Sep 2023 22:50:56 +0200 Subject: [PATCH] Skip deepcopy memo check for empty memo --- Lib/copy.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/copy.py b/Lib/copy.py index 6d7bb9a111b5b4..a69bc4e78c20b3 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)