mirror of
https://github.com/python/cpython.git
synced 2026-01-27 05:05:50 +00:00
gh-143445: Optimize deepcopy for 1.04x speedup (#143449)
Gains according to pyperformance: ``` deepcopy: Mean +- std dev: 411 us +- 2 us -> 396 us +- 3 us: 1.04x faster Significant (t=28.94) deepcopy_reduce: Mean +- std dev: 4.38 us +- 0.05 us -> 4.23 us +- 0.04 us: 1.04x faster Significant (t=20.05) ``` Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
parent
8cf5c4d89a
commit
cea2d2475d
@ -230,7 +230,7 @@ def _reconstruct(x, memo, func, args,
|
||||
*, deepcopy=deepcopy):
|
||||
deep = memo is not None
|
||||
if deep and args:
|
||||
args = (deepcopy(arg, memo) for arg in args)
|
||||
args = [deepcopy(arg, memo) for arg in args]
|
||||
y = func(*args)
|
||||
if deep:
|
||||
memo[id(x)] = y
|
||||
|
||||
@ -1931,6 +1931,7 @@ James Tocknell
|
||||
Bennett Todd
|
||||
R Lindsay Todd
|
||||
Eugene Toder
|
||||
Heikki Toivonen
|
||||
Erik Tollerud
|
||||
Stephen Tonkin
|
||||
Matias Torchinsky
|
||||
|
||||
@ -0,0 +1 @@
|
||||
Speed up :func:`copy.deepcopy` by 1.04x.
|
||||
Loading…
x
Reference in New Issue
Block a user