Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-123745: Improve performance of deepcopy by setting keep alive key in the memo#123746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
eendebakpt wants to merge5 commits intopython:main
base:main
Choose a base branch
Loading
fromeendebakpt:dc_memo

Conversation

eendebakpt
Copy link
Contributor

@eendebakpteendebakpt commentedSep 5, 2024
edited by bedevere-appbot
Loading

Benchmark:

import pyperfrunner = pyperf.Runner()setup="""import copya={'list': [1,2,3,43], 't': (1,2,3), 'str': 'hello', 'subdict': {'a': True}}from dataclasses import dataclasslst = [1, 's']@dataclassclass A:    a : int    dc = A(123)list_dc = [A(1), A(2), A(3), A(4)]"""runner.timeit(name="deepcopy dict", stmt=f"b=copy.deepcopy(a)", setup=setup)runner.timeit(name="deepcopy dataclass", stmt=f"b=copy.deepcopy(dc)", setup=setup)runner.timeit(name="deepcopy small list", stmt=f"b=copy.deepcopy(lst)", setup=setup)runner.timeit(name="deepcopy list dataclasses", stmt=f"b=copy.deepcopy(list_dc)", setup=setup)

Results:

deepcopy dict: Mean +- std dev: [main] 11.3 us +- 0.9 us -> [pr] 10.2 us +- 0.1 us: 1.11x fasterdeepcopy dataclass: Mean +- std dev: [main] 8.62 us +- 0.29 us -> [pr] 7.74 us +- 0.30 us: 1.11x fasterdeepcopy small list: Mean +- std dev: [main] 2.48 us +- 0.10 us -> [pr] 2.20 us +- 0.31 us: 1.13x fasterdeepcopy list dataclasses: Mean +- std dev: [main] 34.1 us +- 1.3 us -> [pr] 32.9 us +- 1.0 us: 1.03x fasterGeometric mean: 1.10x faster

See the corresponding issue for further details.

lgeiger reacted with thumbs up emoji
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@eendebakpt

[8]ページ先頭

©2009-2025 Movatter.jp