René's URL Explorer Experiment


Title: gh-114264: Optimize performance of copy.deepcopy by adding a fast path for atomic types by eendebakpt · Pull Request #114266 · python/cpython · GitHub

Open Graph Title: gh-114264: Optimize performance of copy.deepcopy by adding a fast path for atomic types by eendebakpt · Pull Request #114266 · python/cpython

X Title: gh-114264: Optimize performance of copy.deepcopy by adding a fast path for atomic types by eendebakpt · Pull Request #114266 · python/cpython

Description: By adding a fast path for atomic types we eliminate the overhead of checking the memo argument of deepcopy and the overhead of calling the dispatch method. Benchmark: deepcopy dict: Mean +- std dev: [main] 6.88 us +- 0.08 us -> [pr] 4.65 us +- 0.06 us: 1.48x faster deepcopy dataclass: Mean +- std dev: [main] 6.64 us +- 0.11 us -> [pr] 5.23 us +- 0.07 us: 1.27x faster deepcopy small tuple: Mean +- std dev: [main] 1.07 us +- 0.01 us -> [pr] 924 ns +- 33 ns: 1.16x faster Geometric mean: 1.30x faster Benchmark script: import pyperf runner = pyperf.Runner() setup=""" import copy a={'list': [1,2,3,43], 't': (1,2,3), 'str': 'hello', 'subdict': {'a': True}} from dataclasses import dataclass @dataclass class A: a : list b : str c : bool dc=A([1,2,3], 'hello', True) small_tuple = (1, ) """ runner.timeit(name=f"deepcopy dict", stmt=f"b=copy.deepcopy(a)", setup=setup) runner.timeit(name=f"deepcopy dataclass", stmt=f"b=copy.deepcopy(dc)", setup=setup) runner.timeit(name=f"deepcopy small tuple", stmt=f"b=copy.deepcopy(small_tuple)", setup=setup) The approach is similar to the one used in #103005 Issue: gh-114264

Open Graph Description: By adding a fast path for atomic types we eliminate the overhead of checking the memo argument of deepcopy and the overhead of calling the dispatch method. Benchmark: deepcopy dict: Mean +- std dev...

X Description: By adding a fast path for atomic types we eliminate the overhead of checking the memo argument of deepcopy and the overhead of calling the dispatch method. Benchmark: deepcopy dict: Mean +- std dev...

Opengraph URL: https://github.com/python/cpython/pull/114266

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:5ad09595-a4fb-9ed9-fb01-f759582c38d2
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE684:35B8D6:20EE3D8:2D4A5D9:696ABA5E
html-safe-nonce467fa28346ead701d9c41b1d40449bc9dde187139e50c292bf463b0c2b828895
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNjg0OjM1QjhENjoyMEVFM0Q4OjJENEE1RDk6Njk2QUJBNUUiLCJ2aXNpdG9yX2lkIjoiMjcwNDA5ODc5NzAxMTI1Mzg1NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacaf99437c2716f9ac97f7cc90293e7938c83e3d42f9626ec55b7b7225a4c29077
hovercard-subject-tagpull_request:1685560550
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/114266/files
twitter:imagehttps://avatars.githubusercontent.com/u/883786?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/883786?s=400&v=4
og:image:altBy adding a fast path for atomic types we eliminate the overhead of checking the memo argument of deepcopy and the overhead of calling the dispatch method. Benchmark: deepcopy dict: Mean +- std dev...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None46ce962e0e18113ea447391b6ace8b02d4d2861e57b4fbab3658698f73d8855b
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release30300f30bb3949de255e84a146706a3bdb5c19c9
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/114266/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F114266%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F114266%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/114266/files
Reloadhttps://github.com/python/cpython/pull/114266/files
Reloadhttps://github.com/python/cpython/pull/114266/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/114266/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/pull/114266/files
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
serhiy-storchakahttps://github.com/serhiy-storchaka
python:mainhttps://github.com/python/cpython/tree/main
eendebakpt:deepcopy_atomic_typeshttps://github.com/eendebakpt/cpython/tree/deepcopy_atomic_types
Conversation 22 https://github.com/python/cpython/pull/114266
Commits 23 https://github.com/python/cpython/pull/114266/commits
Checks 0 https://github.com/python/cpython/pull/114266/checks
Files changed https://github.com/python/cpython/pull/114266/files
Please reload this pagehttps://github.com/python/cpython/pull/114266/files
gh-114264: Optimize performance of copy.deepcopy by adding a fast path for atomic types https://github.com/python/cpython/pull/114266/files#top
Show all changes 23 commits https://github.com/python/cpython/pull/114266/files
9990245 Optimize performance of copy.deepcopy by adding a fast path for atomi… eendebakpt Jan 18, 2024 https://github.com/python/cpython/pull/114266/commits/9990245b3d441820d6576f679d9ce6e291e71b49
06f1980 match order with main eendebakpt Jan 18, 2024 https://github.com/python/cpython/pull/114266/commits/06f1980fa6236f3403ffd34597ee453ba4fd2c8f
dd9fabf 📜🤖 Added by blurb_it. blurb-it[bot] Jan 18, 2024 https://github.com/python/cpython/pull/114266/commits/dd9fabfaf4f089865ff68445d53555f265e43c41
becbb59 format news entry eendebakpt Jan 18, 2024 https://github.com/python/cpython/pull/114266/commits/becbb591cc5a83d477edbd1c57435bcfe79b6745
339c2b9 put d variable back eendebakpt Jan 19, 2024 https://github.com/python/cpython/pull/114266/commits/339c2b9551482dc580bc2cb6ed49a480f11a6e75
89ecad1 Merge branch 'deepcopy_atomic_types' of github.com:eendebakpt/cpython… eendebakpt Jan 19, 2024 https://github.com/python/cpython/pull/114266/commits/89ecad1f3b9d03cc6b47b09e2cedc8e429c34d08
9aacf87 Merge branch 'main' into deepcopy_atomic_types eendebakpt Jan 30, 2024 https://github.com/python/cpython/pull/114266/commits/9aacf87f8b60c476eba4b2b84694d54a48096a6b
5197f94 Merge branch 'main' into deepcopy_atomic_types eendebakpt Feb 4, 2024 https://github.com/python/cpython/pull/114266/commits/5197f943c55ee1ad8dc1045ed5a083625325f243
18914f3 Merge branch 'main' into deepcopy_atomic_types eendebakpt Feb 26, 2024 https://github.com/python/cpython/pull/114266/commits/18914f3756167bc24e88684ddda2fa236604e20d
8f294c7 Merge branch 'main' into deepcopy_atomic_types eendebakpt Feb 26, 2024 https://github.com/python/cpython/pull/114266/commits/8f294c7f8e566635aa85c1900f26fb5c60008d9c
3b57fc1 Merge branch 'main' into deepcopy_atomic_types eendebakpt Mar 18, 2024 https://github.com/python/cpython/pull/114266/commits/3b57fc1f3662c629cb9cc84d61bffade44b74067
53d63a7 Merge branch 'main' into deepcopy_atomic_types eendebakpt Mar 29, 2024 https://github.com/python/cpython/pull/114266/commits/53d63a79f91abf0c4310413fae32196aefd21c30
eb8e6ba improve performance of _deepcopy_list with a list comprehension eendebakpt Apr 13, 2024 https://github.com/python/cpython/pull/114266/commits/eb8e6ba35cf7a1826fe756a5281b70af5531acfa
e468b6c avoid generation of exception in _deepcopy_tuple eendebakpt Apr 13, 2024 https://github.com/python/cpython/pull/114266/commits/e468b6c5169c124e567885d29d388fb757f2bf5d
2b4abe6 Merge branch 'main' into deepcopy_atomic_types eendebakpt Apr 13, 2024 https://github.com/python/cpython/pull/114266/commits/2b4abe6da927ba02ffaa9209b591e23d3ad83db1
e3310f5 revert comprehension changes eendebakpt Apr 14, 2024 https://github.com/python/cpython/pull/114266/commits/e3310f5731db181c40e7e758b59cbab454a0455c
1186a5b Merge branch 'deepcopy_atomic_types' of github.com:eendebakpt/cpython… eendebakpt Apr 14, 2024 https://github.com/python/cpython/pull/114266/commits/1186a5b2079e6c1c8162d549db09c20b5ba088d1
ce7273b Merge branch 'main' into deepcopy_atomic_types eendebakpt Apr 20, 2024 https://github.com/python/cpython/pull/114266/commits/ce7273b08a2f6e25d4b889e594f86d798c559c36
4bc74d3 Update Lib/copy.py eendebakpt May 1, 2024 https://github.com/python/cpython/pull/114266/commits/4bc74d3fda5c39bcecdd5bebcf909477dcc4a6da
d69d8da Merge branch 'main' into deepcopy_atomic_types eendebakpt May 1, 2024 https://github.com/python/cpython/pull/114266/commits/d69d8da33ee73876b4add59a80807e2f317a8b10
c66b24d Apply suggestions from code review eendebakpt May 1, 2024 https://github.com/python/cpython/pull/114266/commits/c66b24d5ad017414ebf9feb6bc92d50f56a6733d
142b0fc Merge branch 'main' into deepcopy_atomic_types eendebakpt May 6, 2024 https://github.com/python/cpython/pull/114266/commits/142b0fcc0fff81567235d2e6109175e365483c67
d6fa670 Merge branch 'main' into deepcopy_atomic_types eendebakpt Jun 1, 2024 https://github.com/python/cpython/pull/114266/commits/d6fa67047d14b113797117579c540841a032ed75
Clear filters https://github.com/python/cpython/pull/114266/files
Please reload this pagehttps://github.com/python/cpython/pull/114266/files
Please reload this pagehttps://github.com/python/cpython/pull/114266/files
copy.py https://github.com/python/cpython/pull/114266/files#diff-a06198e13686594114a45e7863b954a226ce08d43f724079faa7fe8b3c931703
2024-01-18-21-44-23.gh-issue-114264.DBKn29.rst https://github.com/python/cpython/pull/114266/files#diff-6b3d44a3960debbb9d3cb5f6b706c61a138299062eb90f77ad7b5d66d6e26e53
Lib/copy.pyhttps://github.com/python/cpython/pull/114266/files#diff-a06198e13686594114a45e7863b954a226ce08d43f724079faa7fe8b3c931703
View file https://github.com/eendebakpt/cpython/blob/d6fa67047d14b113797117579c540841a032ed75/Lib/copy.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/114266/{{ revealButtonHref }}
https://github.com/python/cpython/pull/114266/files#diff-a06198e13686594114a45e7863b954a226ce08d43f724079faa7fe8b3c931703
sunmy2019https://github.com/sunmy2019
Jan 19, 2024https://github.com/python/cpython/pull/114266/files#r1458467568
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/114266/files
gaogaotiantianhttps://github.com/gaogaotiantian
Jan 19, 2024https://github.com/python/cpython/pull/114266/files#r1458520131
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/114266/files
eendebakpthttps://github.com/eendebakpt
Jan 19, 2024https://github.com/python/cpython/pull/114266/files#r1458727771
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/114266/files
serhiy-storchakahttps://github.com/serhiy-storchaka
Jan 19, 2024https://github.com/python/cpython/pull/114266/files#r1458755467
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/114266/files
eendebakpthttps://github.com/eendebakpt
Jan 19, 2024https://github.com/python/cpython/pull/114266/files#r1459715308
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
@serhiy-storchakahttps://github.com/serhiy-storchaka
main...eendebakpt:deepcopy_atomic_types_v3https://github.com/python/cpython/compare/main...eendebakpt:deepcopy_atomic_types_v3
main...eendebakpt:deepcopy_atomic_types_v4https://github.com/python/cpython/compare/main...eendebakpt:deepcopy_atomic_types_v4
Please reload this pagehttps://github.com/python/cpython/pull/114266/files
gaogaotiantianhttps://github.com/gaogaotiantian
Jan 19, 2024https://github.com/python/cpython/pull/114266/files#r1459834592
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/114266/files
sunmy2019https://github.com/sunmy2019
Jan 20, 2024https://github.com/python/cpython/pull/114266/files#r1460292797
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/114266/files
serhiy-storchakahttps://github.com/serhiy-storchaka
Jan 20, 2024https://github.com/python/cpython/pull/114266/files#r1460324317
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/114266/files
eendebakpthttps://github.com/eendebakpt
Jan 22, 2024https://github.com/python/cpython/pull/114266/files#r1462470763
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
main...eendebakpt:deepcopy_atomic_types_v3https://github.com/python/cpython/compare/main...eendebakpt:deepcopy_atomic_types_v3
main...eendebakpt:deepcopy_atomic_types_v4https://github.com/python/cpython/compare/main...eendebakpt:deepcopy_atomic_types_v4
gh-72793: C implementation of parts of copy.deepcopy #91610https://github.com/python/cpython/pull/91610
Please reload this pagehttps://github.com/python/cpython/pull/114266/files
https://github.com/python/cpython/pull/114266/files#diff-a06198e13686594114a45e7863b954a226ce08d43f724079faa7fe8b3c931703
https://github.com/python/cpython/pull/114266/files#diff-a06198e13686594114a45e7863b954a226ce08d43f724079faa7fe8b3c931703
https://github.com/python/cpython/pull/114266/files#diff-a06198e13686594114a45e7863b954a226ce08d43f724079faa7fe8b3c931703
Please reload this pagehttps://github.com/python/cpython/pull/114266/files
https://github.com/python/cpython/pull/114266/files#diff-a06198e13686594114a45e7863b954a226ce08d43f724079faa7fe8b3c931703
Misc/NEWS.d/next/Library/2024-01-18-21-44-23.gh-issue-114264.DBKn29.rsthttps://github.com/python/cpython/pull/114266/files#diff-6b3d44a3960debbb9d3cb5f6b706c61a138299062eb90f77ad7b5d66d6e26e53
View file https://github.com/eendebakpt/cpython/blob/d6fa67047d14b113797117579c540841a032ed75/Misc/NEWS.d/next/Library/2024-01-18-21-44-23.gh-issue-114264.DBKn29.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/114266/{{ revealButtonHref }}
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.