Skip to content

Commit b8c57fa

Browse files
committed
move atomic check before memo check
1 parent 89ded2a commit b8c57fa

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Lib/copy.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ def deepcopy(x, memo=None, _nil=[]):
121121
See the module's __doc__ string for more info.
122122
"""
123123

124+
cls = type(x)
125+
copier = _deepcopy_dispatch.get(cls)
126+
127+
if copier is ...:
128+
# atomic type
129+
return x
130+
124131
d = id(x)
125132
if memo is None:
126133
memo = {}
@@ -129,13 +136,6 @@ def deepcopy(x, memo=None, _nil=[]):
129136
if y is not _nil:
130137
return y
131138

132-
cls = type(x)
133-
134-
copier = _deepcopy_dispatch.get(cls)
135-
136-
if copier is ...:
137-
# atomic type
138-
return x
139139

140140
if copier is not None:
141141
y = copier(x, memo)

0 commit comments

Comments
 (0)