René's URL Explorer Experiment


Title: gh-98169 dataclasses.astuple support DefaultDict by kwsp · Pull Request #98170 · python/cpython · GitHub

Open Graph Title: gh-98169 dataclasses.astuple support DefaultDict by kwsp · Pull Request #98170 · python/cpython

X Title: gh-98169 dataclasses.astuple support DefaultDict by kwsp · Pull Request #98170 · python/cpython

Description: Basically applying the same fix for asdict from #32056 to astuple. These two should've been the same PR, but I didn't know about astuple previously. Also modified the handling of DefaultDict in asdict a little so that we only call isinstance(obj, dict) once. This results in a ~3% speed up on my machine on this example: # benchmark from dataclasses import dataclass, asdict from collections import defaultdict from typing import DefaultDict, Dict, List, NamedTuple import time class NT(NamedTuple): x: int y: float @dataclass class C: dd: DefaultDict[str, List] nt: NT d1: Dict[str, List] d2: Dict[str, int] def get_instance(): instance = C(dd=defaultdict(list), nt=NT(1, 1.), d1={}, d2={}) instance.dd["x"].append(12) instance.dd["x"].append(13) instance.d1["y"] = [1, 2, 3] instance.d2["z"] = 1 return instance instance = get_instance() def timeit(callable, n_runs = 100_000, name=""): t1 = time.perf_counter_ns() for _ in range(n_runs): callable() elapsed_ms = round(1e-6 * (time.perf_counter_ns() - t1), 2) print(f"{name}\t{n_runs} runs: {elapsed_ms} ms") timeit(lambda: asdict(instance), name="asdict") timeit(lambda: astuple(instance), name="astuple") Issue: gh-98169

Open Graph Description: Basically applying the same fix for asdict from #32056 to astuple. These two should've been the same PR, but I didn't know about astuple previously. Also modified the handling of DefaultDic...

X Description: Basically applying the same fix for asdict from #32056 to astuple. These two should've been the same PR, but I didn't know about astuple previously. Also modified the handling of De...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:1f3eec6c-08fd-8d1f-f492-ff16007b85b7
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idAF1C:281585:7991D2:AA55F4:696A2A39
html-safe-nonce1904b431b0e7167274dc96ff2482a336f59efa9b6746810f8a4a213de9a3fe25
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjFDOjI4MTU4NTo3OTkxRDI6QUE1NUY0OjY5NkEyQTM5IiwidmlzaXRvcl9pZCI6Ijg1MTI5NTM3OTQ2ODMzNDk1NjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacca6f7983ea79a229eddef0b3d434234e82fb6ced1f8b6cfe2d107836b4ac006b
hovercard-subject-tagpull_request:1082614604
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/98170/files
twitter:imagehttps://avatars.githubusercontent.com/u/30088608?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/30088608?s=400&v=4
og:image:altBasically applying the same fix for asdict from #32056 to astuple. These two should've been the same PR, but I didn't know about astuple previously. Also modified the handling of DefaultDic...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneade130928b3890d20ecf9c887468a17e88d5c9a740ea2a85c2c2162e7c58e623
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
releasec00842167ca2e5b13e8171812965d503e925ece6
ui-targetcanary-1
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/98170/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F98170%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%2F98170%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/98170/files
Reloadhttps://github.com/python/cpython/pull/98170/files
Reloadhttps://github.com/python/cpython/pull/98170/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/98170/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/98170/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
carljmhttps://github.com/carljm
python:mainhttps://github.com/python/cpython/tree/main
kwsp:dataclasshttps://github.com/kwsp/cpython/tree/dataclass
Conversation 9 https://github.com/python/cpython/pull/98170
Commits 5 https://github.com/python/cpython/pull/98170/commits
Checks 0 https://github.com/python/cpython/pull/98170/checks
Files changed https://github.com/python/cpython/pull/98170/files
Please reload this pagehttps://github.com/python/cpython/pull/98170/files
gh-98169 dataclasses.astuple support DefaultDict https://github.com/python/cpython/pull/98170/files#top
Show all changes 5 commits https://github.com/python/cpython/pull/98170/files
81d9170 gh-98169 dataclasses.astuple support DefaultDict kwsp Oct 9, 2022 https://github.com/python/cpython/pull/98170/commits/81d917079ffb35bc835f835b1dcee25b4b9049af
8aa1b3d removed links to the bugs kwsp Oct 11, 2022 https://github.com/python/cpython/pull/98170/commits/8aa1b3dff4865535d9b4bbefe5a6f6c02425536a
f39e3d8 news.d kwsp Oct 11, 2022 https://github.com/python/cpython/pull/98170/commits/f39e3d8e2cd8b7b58e16ee9e9e5892c24a82447d
fc6a5a9 Update Lib/dataclasses.py kwsp Mar 13, 2023 https://github.com/python/cpython/pull/98170/commits/fc6a5a9682d7599366ecc8faf4233af02d8de949
44aaee9 Update Lib/dataclasses.py kwsp Mar 13, 2023 https://github.com/python/cpython/pull/98170/commits/44aaee9b958cc72d8a4954f0475c8dd19657d760
Clear filters https://github.com/python/cpython/pull/98170/files
Please reload this pagehttps://github.com/python/cpython/pull/98170/files
Please reload this pagehttps://github.com/python/cpython/pull/98170/files
dataclasses.py https://github.com/python/cpython/pull/98170/files#diff-44ce2dc1c4922b2f5cf7631d8f86cc569a4c25eb003aaecdc2bc22eb9163d5f5
test_dataclasses.py https://github.com/python/cpython/pull/98170/files#diff-f0436842533448f8f02a19081d7c9cc8372b6685756caf32c83dfecebbee68e7
2022-10-10-19-14-51.gh-issue-98169.DBWIxL.rst https://github.com/python/cpython/pull/98170/files#diff-1cde6b30fc88fde046e5311cb190167fb23cdbb85defc2e8c5f34749ccdf0121
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L415
Lib/dataclasses.pyhttps://github.com/python/cpython/pull/98170/files#diff-44ce2dc1c4922b2f5cf7631d8f86cc569a4c25eb003aaecdc2bc22eb9163d5f5
View file https://github.com/kwsp/cpython/blob/44aaee9b958cc72d8a4954f0475c8dd19657d760/Lib/dataclasses.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/98170/{{ revealButtonHref }}
https://github.com/python/cpython/pull/98170/files#diff-44ce2dc1c4922b2f5cf7631d8f86cc569a4c25eb003aaecdc2bc22eb9163d5f5
Please reload this pagehttps://github.com/python/cpython/pull/98170/files
https://github.com/python/cpython/pull/98170/files#diff-44ce2dc1c4922b2f5cf7631d8f86cc569a4c25eb003aaecdc2bc22eb9163d5f5
https://github.com/python/cpython/pull/98170/files#diff-44ce2dc1c4922b2f5cf7631d8f86cc569a4c25eb003aaecdc2bc22eb9163d5f5
https://github.com/python/cpython/pull/98170/files#diff-44ce2dc1c4922b2f5cf7631d8f86cc569a4c25eb003aaecdc2bc22eb9163d5f5
Lib/test/test_dataclasses.pyhttps://github.com/python/cpython/pull/98170/files#diff-f0436842533448f8f02a19081d7c9cc8372b6685756caf32c83dfecebbee68e7
View file https://github.com/kwsp/cpython/blob/44aaee9b958cc72d8a4954f0475c8dd19657d760/Lib/test/test_dataclasses.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/98170/{{ revealButtonHref }}
https://github.com/python/cpython/pull/98170/files#diff-f0436842533448f8f02a19081d7c9cc8372b6685756caf32c83dfecebbee68e7
https://github.com/python/cpython/pull/98170/files#diff-f0436842533448f8f02a19081d7c9cc8372b6685756caf32c83dfecebbee68e7
https://github.com/python/cpython/pull/98170/files#diff-f0436842533448f8f02a19081d7c9cc8372b6685756caf32c83dfecebbee68e7
https://github.com/python/cpython/pull/98170/files#diff-f0436842533448f8f02a19081d7c9cc8372b6685756caf32c83dfecebbee68e7
Misc/NEWS.d/next/Library/2022-10-10-19-14-51.gh-issue-98169.DBWIxL.rsthttps://github.com/python/cpython/pull/98170/files#diff-1cde6b30fc88fde046e5311cb190167fb23cdbb85defc2e8c5f34749ccdf0121
View file https://github.com/kwsp/cpython/blob/44aaee9b958cc72d8a4954f0475c8dd19657d760/Misc/NEWS.d/next/Library/2022-10-10-19-14-51.gh-issue-98169.DBWIxL.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/98170/{{ 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.