Skip to content

Commit ba7298c

Browse files
committed
Don't call len for checking for empty container
1 parent 68c589f commit ba7298c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Lib/copy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def deepcopy(x, memo=None, _nil=[]):
127127
return x
128128

129129
if memo is None:
130-
if cls in _builtin_iterables and len(x) == 0:
130+
if cls in _builtin_iterables and not x:
131131
return cls()
132132
d = id(x)
133133
memo = {}
@@ -137,7 +137,7 @@ def deepcopy(x, memo=None, _nil=[]):
137137
if y is not _nil:
138138
return y
139139

140-
if cls in _builtin_iterables and len(x) == 0:
140+
if cls in _builtin_iterables and not x:
141141
y = cls()
142142
elif copier := _deepcopy_dispatch.get(cls):
143143
y = copier(x, memo)

0 commit comments

Comments
 (0)