@@ -123,11 +123,11 @@ def deepcopy(x, memo=None, _nil=[]):
123
123
124
124
cls = type (x )
125
125
126
- if cls in _atomic_types or ( cls in _immutable_iterables and len ( x ) == 0 ) :
126
+ if cls in _atomic_types :
127
127
return x
128
128
129
129
if memo is None :
130
- if cls in _mutable_iterables and len (x ) == 0 :
130
+ if cls in _builtin_iterables and len (x ) == 0 :
131
131
return cls ()
132
132
d = id (x )
133
133
memo = {}
@@ -137,7 +137,7 @@ def deepcopy(x, memo=None, _nil=[]):
137
137
if y is not _nil :
138
138
return y
139
139
140
- if cls in _mutable_iterables and len (x ) == 0 :
140
+ if cls in _builtin_iterables and len (x ) == 0 :
141
141
y = cls ()
142
142
elif copier := _deepcopy_dispatch .get (cls ):
143
143
y = copier (x , memo )
@@ -177,8 +177,7 @@ def deepcopy(x, memo=None, _nil=[]):
177
177
_atomic_types = {types .NoneType , types .EllipsisType , types .NotImplementedType ,
178
178
int , float , bool , complex , bytes , str , types .CodeType , type , range ,
179
179
types .BuiltinFunctionType , types .FunctionType , weakref .ref , property }
180
- _mutable_iterables = {list , dict , set }
181
- _immutable_iterables = {tuple , frozenset }
180
+ _builtin_iterables = {tuple , list , dict , set , frozenset }
182
181
183
182
_deepcopy_dispatch = d = {}
184
183
0 commit comments