René's URL Explorer Experiment


Title: gh-89550: Buffer GzipFile.write to reduce execution time by ~15% by CCLDArjun · Pull Request #101251 · python/cpython · GitHub

Open Graph Title: gh-89550: Buffer GzipFile.write to reduce execution time by ~15% by CCLDArjun · Pull Request #101251 · python/cpython

X Title: gh-89550: Buffer GzipFile.write to reduce execution time by ~15% by CCLDArjun · Pull Request #101251 · python/cpython

Description: Currently, all of this is done for every write() call: https://github.com/python/cpython/blob/main/Lib/gzip.py#L266-L288 This pr stores GzipFile.write() data into a buffer to postpone most of the compression work to when the buffer flushes. This way, we can call into zlib and File.write() less frequently. benchmarking with timeit: ../python -m timeit -s 'import gzip ' 'with gzip.open("./Python-3.11.1.tgz", "rb") as infile: ' ' with gzip.open("./Python-3.11.1new.tgz", "wb") as outfile: ' ' for line in infile: ' ' outfile.write(line) ' ' ' 1 loop, best of 5: 6.36 sec per loop vs ../python -m timeit -s 'import gzipold as gzip ' 'with gzip.open("./Python-3.11.1.tgz", "rb") as infile: ' ' with gzip.open("./Python-3.11.1new.tgz", "wb") as outfile: ' ' for line in infile: ' ' outfile.write(line) ' ' ' 1 loop, best of 5: 7.68 sec per loop Issue: gh-89550

Open Graph Description: Currently, all of this is done for every write() call: https://github.com/python/cpython/blob/main/Lib/gzip.py#L266-L288 This pr stores GzipFile.write() data into a buffer to postpone most of the c...

X Description: Currently, all of this is done for every write() call: https://github.com/python/cpython/blob/main/Lib/gzip.py#L266-L288 This pr stores GzipFile.write() data into a buffer to postpone most of the c...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:e3180ce9-c7bd-12dc-6c63-09a241f88d78
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA5DC:46014:194D064:2200A41:6969AE1C
html-safe-nonce9d30a8e08834064bea90a7caed5abdbeff415ce57dc3cff7fea1ad5ec69da9cd
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNURDOjQ2MDE0OjE5NEQwNjQ6MjIwMEE0MTo2OTY5QUUxQyIsInZpc2l0b3JfaWQiOiIyOTA2Nzc2MjYzNTk5OTU5NTgwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacf1cc52d98c151ea71b891349877571c0ed883f645fad634b4ea4abee6695c279
hovercard-subject-tagpull_request:1212758599
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/101251/files
twitter:imagehttps://avatars.githubusercontent.com/u/31632587?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/31632587?s=400&v=4
og:image:altCurrently, all of this is done for every write() call: https://github.com/python/cpython/blob/main/Lib/gzip.py#L266-L288 This pr stores GzipFile.write() data into a buffer to postpone most of the c...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None24c4c97a2d520cb286b35e1a4c22d7a4df3c26a2fa28dd7cdf0e65db327b4de7
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
release124667f43168afb6c9c03b7c02eb5b1d2e1be3d9
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/101251/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F101251%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%2F101251%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/101251/files
Reloadhttps://github.com/python/cpython/pull/101251/files
Reloadhttps://github.com/python/cpython/pull/101251/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/101251/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/101251/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
gpsheadhttps://github.com/gpshead
python:mainhttps://github.com/python/cpython/tree/main
CCLDArjun:buffered-gzip-writeshttps://github.com/CCLDArjun/cpython/tree/buffered-gzip-writes
Conversation 19 https://github.com/python/cpython/pull/101251
Commits 17 https://github.com/python/cpython/pull/101251/commits
Checks 0 https://github.com/python/cpython/pull/101251/checks
Files changed https://github.com/python/cpython/pull/101251/files
Please reload this pagehttps://github.com/python/cpython/pull/101251/files
gh-89550: Buffer GzipFile.write to reduce execution time by ~15% https://github.com/python/cpython/pull/101251/files#top
Show all changes 17 commits https://github.com/python/cpython/pull/101251/files
943ca9c initial testing to see if it's faster CCLDArjun Jan 22, 2023 https://github.com/python/cpython/pull/101251/commits/943ca9c92c9a897d657ea19ea7ed1e7d2f49a289
6f4701b Merge branch 'python:main' into buffered-gzip-writes CCLDArjun Jan 22, 2023 https://github.com/python/cpython/pull/101251/commits/6f4701bb27e94981b8d03cee91af71bce4d9caaf
8653faf use io.BufferedWriter to buffer gzip writes CCLDArjun Jan 22, 2023 https://github.com/python/cpython/pull/101251/commits/8653faf0305db8464ee7cef66e23ebe72d88563a
1c36625 :Merge branch 'buffered-gzip-writes' of https://github.com/ccldarjun/… CCLDArjun Jan 22, 2023 https://github.com/python/cpython/pull/101251/commits/1c366253d5c222b19f8a278d7b248f5699097564
bc4d929 news blurb CCLDArjun Jan 22, 2023 https://github.com/python/cpython/pull/101251/commits/bc4d929e18856b5a2dcc8bbaf002543c67b4c565
ef9dd50 Merge branch 'main' into buffered-gzip-writes CCLDArjun Jan 26, 2023 https://github.com/python/cpython/pull/101251/commits/ef9dd505089d17b595f5a4ed49d94b1dc3d2dc04
b3aa1f7 added buffer_size for file writes CCLDArjun Feb 18, 2023 https://github.com/python/cpython/pull/101251/commits/b3aa1f71b6107e3eccf930e4598eb13d735cc7b2
ad2dc9b :Merge branch 'buffered-gzip-writes' of https://github.com/ccldarjun/… CCLDArjun Feb 18, 2023 https://github.com/python/cpython/pull/101251/commits/ad2dc9bbef60451e91c6888b228f2cc2476f2112
a929ac8 comment for _write_raw CCLDArjun Feb 18, 2023 https://github.com/python/cpython/pull/101251/commits/a929ac8deedeb61971260d894b18f76f035aa17e
d1618f2 common DEFAULT_WRITE_BUFFER_SIZE CCLDArjun Feb 18, 2023 https://github.com/python/cpython/pull/101251/commits/d1618f26050f3a5abcca8625a1aa85fa2beaed6e
a7efd1b Merge branch 'main' into buffered-gzip-writes CCLDArjun Feb 18, 2023 https://github.com/python/cpython/pull/101251/commits/a7efd1b58b0ee3337ca71af45dad5eaf24114809
d0da047 Merge branch 'main' into buffered-gzip-writes CCLDArjun Feb 22, 2023 https://github.com/python/cpython/pull/101251/commits/d0da0473232854ebb7217a0733a8536efc0509ae
fe31588 use constant for write buffer size CCLDArjun Feb 23, 2023 https://github.com/python/cpython/pull/101251/commits/fe31588314f11c40d5a9de54bd15ec746898bf6e
875ebd8 Merge branch 'main' into buffered-gzip-writes CCLDArjun Apr 24, 2023 https://github.com/python/cpython/pull/101251/commits/875ebd86c0400e9a04c26f0561a944692bb3872f
e33fc19 Merge branch 'main' into buffered-gzip-writes AlexWaygood May 8, 2023 https://github.com/python/cpython/pull/101251/commits/e33fc197fcecc26a2f68c95115707965ba7fec8e
5ef4674 improve news wording and ReSTify gpshead May 8, 2023 https://github.com/python/cpython/pull/101251/commits/5ef4674d604ed5415467225c279b23a107657292
c0f3d2a Merge branch 'main' into buffered-gzip-writes gpshead May 8, 2023 https://github.com/python/cpython/pull/101251/commits/c0f3d2a462849dfcae9afcd0327a0bc9dc96ee4c
Clear filters https://github.com/python/cpython/pull/101251/files
Please reload this pagehttps://github.com/python/cpython/pull/101251/files
Please reload this pagehttps://github.com/python/cpython/pull/101251/files
gzip.py https://github.com/python/cpython/pull/101251/files#diff-ad9b54ac8ef847cbb11fb0550f7e8cede55b1d92de15899e0a885a94a124838a
2023-01-22-14-53-12.gh-issue-89550.c1U23f.rst https://github.com/python/cpython/pull/101251/files#diff-6cac834b8c2ad27fa061e8c7285e389b08f6b146962d2d8211aa04a57e6d651f
Lib/gzip.pyhttps://github.com/python/cpython/pull/101251/files#diff-ad9b54ac8ef847cbb11fb0550f7e8cede55b1d92de15899e0a885a94a124838a
View file https://github.com/CCLDArjun/cpython/blob/c0f3d2a462849dfcae9afcd0327a0bc9dc96ee4c/Lib/gzip.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/101251/{{ revealButtonHref }}
https://github.com/python/cpython/pull/101251/files#diff-ad9b54ac8ef847cbb11fb0550f7e8cede55b1d92de15899e0a885a94a124838a
https://github.com/python/cpython/pull/101251/files#diff-ad9b54ac8ef847cbb11fb0550f7e8cede55b1d92de15899e0a885a94a124838a
https://github.com/python/cpython/pull/101251/files#diff-ad9b54ac8ef847cbb11fb0550f7e8cede55b1d92de15899e0a885a94a124838a
https://github.com/python/cpython/pull/101251/files#diff-ad9b54ac8ef847cbb11fb0550f7e8cede55b1d92de15899e0a885a94a124838a
https://github.com/python/cpython/pull/101251/files#diff-ad9b54ac8ef847cbb11fb0550f7e8cede55b1d92de15899e0a885a94a124838a
https://github.com/python/cpython/pull/101251/files#diff-ad9b54ac8ef847cbb11fb0550f7e8cede55b1d92de15899e0a885a94a124838a
https://github.com/python/cpython/pull/101251/files#diff-ad9b54ac8ef847cbb11fb0550f7e8cede55b1d92de15899e0a885a94a124838a
Please reload this pagehttps://github.com/python/cpython/pull/101251/files
https://github.com/python/cpython/pull/101251/files#diff-ad9b54ac8ef847cbb11fb0550f7e8cede55b1d92de15899e0a885a94a124838a
https://github.com/python/cpython/pull/101251/files#diff-ad9b54ac8ef847cbb11fb0550f7e8cede55b1d92de15899e0a885a94a124838a
Please reload this pagehttps://github.com/python/cpython/pull/101251/files
https://github.com/python/cpython/pull/101251/files#diff-ad9b54ac8ef847cbb11fb0550f7e8cede55b1d92de15899e0a885a94a124838a
https://github.com/python/cpython/pull/101251/files#diff-ad9b54ac8ef847cbb11fb0550f7e8cede55b1d92de15899e0a885a94a124838a
https://github.com/python/cpython/pull/101251/files#diff-ad9b54ac8ef847cbb11fb0550f7e8cede55b1d92de15899e0a885a94a124838a
https://github.com/python/cpython/pull/101251/files#diff-ad9b54ac8ef847cbb11fb0550f7e8cede55b1d92de15899e0a885a94a124838a
https://github.com/python/cpython/pull/101251/files#diff-ad9b54ac8ef847cbb11fb0550f7e8cede55b1d92de15899e0a885a94a124838a
https://github.com/python/cpython/pull/101251/files#diff-ad9b54ac8ef847cbb11fb0550f7e8cede55b1d92de15899e0a885a94a124838a
Misc/NEWS.d/next/Library/2023-01-22-14-53-12.gh-issue-89550.c1U23f.rsthttps://github.com/python/cpython/pull/101251/files#diff-6cac834b8c2ad27fa061e8c7285e389b08f6b146962d2d8211aa04a57e6d651f
View file https://github.com/CCLDArjun/cpython/blob/c0f3d2a462849dfcae9afcd0327a0bc9dc96ee4c/Misc/NEWS.d/next/Library/2023-01-22-14-53-12.gh-issue-89550.c1U23f.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/101251/{{ 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.