Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Don't call len for checking for empty container
  • Loading branch information
lgeiger committed Jul 1, 2024
commit ba7298c7ff9801ccac64a3d127b279de5b3524dc
4 changes: 2 additions & 2 deletions Lib/copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def deepcopy(x, memo=None, _nil=[]):
return x

if memo is None:
if cls in _builtin_iterables and len(x) == 0:
if cls in _builtin_iterables and not x:
Comment thread
lgeiger marked this conversation as resolved.
return cls()
d = id(x)
memo = {}
Expand All @@ -137,7 +137,7 @@ def deepcopy(x, memo=None, _nil=[]):
if y is not _nil:
return y

if cls in _builtin_iterables and len(x) == 0:
if cls in _builtin_iterables and not x:
Comment thread
lgeiger marked this conversation as resolved.
Outdated
y = cls()
elif copier := _deepcopy_dispatch.get(cls):
y = copier(x, memo)
Expand Down