mirror of
https://github.com/python/cpython.git
synced 2025-10-08 08:01:55 +00:00
- Patch 1433928:
- The copy module now "copies" function objects (as atomic objects). - dict.__getitem__ now looks for a __missing__ hook before raising KeyError. - Added a new type, defaultdict, to the collections module. This uses the new __missing__ hook behavior added to dict (see above).
This commit is contained in:
parent
ab51f5f24d
commit
1968ad32cd
12 changed files with 611 additions and 10 deletions
|
@ -101,7 +101,8 @@ def _copy_immutable(x):
|
|||
return x
|
||||
for t in (type(None), int, long, float, bool, str, tuple,
|
||||
frozenset, type, xrange, types.ClassType,
|
||||
types.BuiltinFunctionType):
|
||||
types.BuiltinFunctionType,
|
||||
types.FunctionType):
|
||||
d[t] = _copy_immutable
|
||||
for name in ("ComplexType", "UnicodeType", "CodeType"):
|
||||
t = getattr(types, name, None)
|
||||
|
@ -217,6 +218,7 @@ d[type] = _deepcopy_atomic
|
|||
d[xrange] = _deepcopy_atomic
|
||||
d[types.ClassType] = _deepcopy_atomic
|
||||
d[types.BuiltinFunctionType] = _deepcopy_atomic
|
||||
d[types.FunctionType] = _deepcopy_atomic
|
||||
|
||||
def _deepcopy_list(x, memo):
|
||||
y = []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue