GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-91349: Adjust default compression level to 6 (down from 9) in gzip and tarfile by morotti · Pull Request #131470 · python/cpython

Conversation

@morotti

@morotti morotti commented Mar 19, 2025 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

It is the default level used by most compression tools and a better tradeoff between speed and performance.

see discussion in #91349 (comment)

  • Issue: Use zlib-ng (fast!) rather than mainline stale zlib in binary releases #91349

📚 Documentation preview 📚: https://cpython-previews--131470.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

barneygale, Zaczero, mxmlnkn, gpshead, and jonbannister reacted with thumbs up emoji
All reactions
  • 👍 5 reactions
@morotti
morotti requested a review from ethanfurman as a code owner March 19, 2025 16:11
@bedevere-app bedevere-app Bot added the awaiting review label Mar 19, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Mar 19, 2025
Use zlib-ng (fast!) rather than mainline stale zlib in binary releases #91349
Closed
@merwok merwok added awaiting core review stdlib Standard Library Python modules in the Lib/ directory type-feature A feature request or enhancement and removed awaiting core review labels May 19, 2025
@morotti
morotti force-pushed the rmorotti-compresion-level branch from e2d0562 to a2d0966 Compare June 25, 2025 13:22
@rmmancom
pythongh-91349: Adjust default compression level to 6 (down from 9) i…
b17e21d
…n gzip and tarfile

It is the default level used by most compression tools and a
better tradeoff between speed and performance.
@morotti
morotti force-pushed the rmorotti-compresion-level branch from a2d0966 to b17e21d Compare June 25, 2025 13:31
merwok
merwok reviewed Jun 25, 2025
View reviewed changes
Comment thread Doc/library/gzip.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

rmmancom added 2 commits June 25, 2025 15:32
@rmmancom
add versionchanged note
7ba376e
@rmmancom
add versionchanged note
461178f
@morotti

morotti commented Jun 25, 2025

Copy link
Copy Markdown
Contributor Author

@merwok I added the versionchanged notes. and found another comment in tarfile.rst to adjust.
it's a bit repetitive to add on each signature I suppose but I suppose it's fine.

You can review again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@emmatyping emmatyping removed type-feature A feature request or enhancement stdlib Standard Library Python modules in the Lib/ directory labels Jun 26, 2025
@morotti

morotti commented Jun 27, 2025

Copy link
Copy Markdown
Contributor Author

@gpshead you've replied multiple times to my questions on improving compression code with "PR welcome". maybe you would be interested in reviewing this PR?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@morotti

morotti commented Jul 18, 2025

Copy link
Copy Markdown
Contributor Author

can anybody review the PR please?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

eendebakpt
eendebakpt reviewed Jul 18, 2025
View reviewed changes
Comment thread Doc/library/gzip.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

eendebakpt
eendebakpt reviewed Jul 18, 2025
View reviewed changes
Comment thread Doc/library/gzip.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

eendebakpt
eendebakpt reviewed Jul 18, 2025
View reviewed changes
Comment thread Doc/library/gzip.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@morotti

morotti commented Jul 18, 2025

Copy link
Copy Markdown
Contributor Author

are you two saying that this fix will not be able to ship with python 3.14?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@morotti @eendebakpt
Update Doc/library/gzip.rst
93ea66a
set versionchanged to next

Co-authored-by: Pieter Eendebak <[email protected]>
morotti
morotti commented Jul 18, 2025
View reviewed changes
Comment thread Doc/library/gzip.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@morotti
Update Doc/library/gzip.rst
b2dd727
set versionchanged to next
morotti
morotti commented Jul 18, 2025
View reviewed changes
Comment thread Doc/library/gzip.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@morotti
set versionchanged to next
f924161
morotti
morotti commented Jul 18, 2025
View reviewed changes
Comment thread Doc/library/tarfile.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@morotti
Update Doc/library/tarfile.rst
808f7cd
set versionchanged to next
@morotti

morotti commented Jul 18, 2025

Copy link
Copy Markdown
Contributor Author

done, adjusted all the versionchanged to next

gpshead reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@merwok merwok added the 3.15 bugs and security fixes label Jul 18, 2025
@gpshead

gpshead commented Jul 19, 2025

Copy link
Copy Markdown
Member

wow, checking the source history it looks like "9" was used when the gzip module was added circa 1997. ironic, i'd have never expected that as a default. "6" being the bare "gzip" default value is just a well known thing.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gpshead
gpshead approved these changes Jul 19, 2025
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2025-03-19-12-41-42.gh-issue-91349.8eTOCP.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Jul 19, 2025
morotti
morotti commented Jul 20, 2025
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2025-03-19-12-41-42.gh-issue-91349.8eTOCP.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@morotti
Update Misc/NEWS.d/next/Library/2025-03-19-12-41-42.gh-issue-91349.8e…
793ca56
…TOCP.rst


highlight function in rst file
@morotti

morotti commented Jul 20, 2025

Copy link
Copy Markdown
Contributor Author

@ethanfurman the PR says it's "pending review" from you, can you approve?

@gpshead I adjusted the rst to highlight the function, as per the code suggestion.

Indeed, the very first commit from April 1997 set the compression level to 9. It's been wrong for 28 years. :D

I first came across this bug about 9 years ago, when using tornado (web framework). It took whole seconds to compress HTTP responses with the gzip=9 default and slow down every request (whole seconds of delay to compress a couple MB). Tornado was patched to set compresslevel=6 but I never came around to fix the interpreter until now. This PR is the fix of a lifetime :D

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gpshead
gpshead approved these changes Jul 20, 2025
View reviewed changes
@gpshead
gpshead merged commit e24c66d into python:main Jul 20, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Jul 20, 2025
@merwok

merwok commented Jul 23, 2025

Copy link
Copy Markdown
Member

It seems that I misinterpreted the status of 3.14: rc phase started today, we were in beta before. Would this change (accepted 2 days ago) have been ok for 3.14 @hugovk ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gpshead

gpshead commented Jul 23, 2025

Copy link
Copy Markdown
Member

Entirely up to Hugo. I personally wouldn't bother trying to put this in 3.14 in the rc phase. The perhaps unusual default has been that way for decades now so there is no urgency in changing it. People who want speed are already passing their own compresslevel, or when possible, using a far more modern algorithm than venerable zlib based gzip.

merwok and hugovk reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
@morotti @rmmancom
@eendebakpt @taegyunkim
pythongh-91349: Adjust default compression level to 6 (down from 9) i…
392e350
…n gzip and tarfile (pythonGH-131470)

pythongh-91349: Adjust default compression level to 6 (down from 9) in gzip and tarfile

It is the default level used by most compression tools and a
better tradeoff between speed and performance.

Co-authored-by: rmorotti <[email protected]>
Co-authored-by: Pieter Eendebak <[email protected]>
@hugovk

hugovk commented Aug 7, 2025

Copy link
Copy Markdown
Member

Yeah, let's keep it for 3.15.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dolfinus dolfinus mentioned this pull request Aug 8, 2025
Python: Change gzip compression level in HttpTransport OpenLineage/OpenLineage#3956
Merged
4 of 8 tasks
@dolfinus dolfinus mentioned this pull request Aug 15, 2025
Severe performance degradation after migrating to cramjam LZ4 aio-libs/aiokafka#1028
Open
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
@morotti @rmmancom
@eendebakpt @Agent-Hellboy
pythongh-91349: Adjust default compression level to 6 (down from 9) i…
8183407
…n gzip and tarfile (pythonGH-131470)

pythongh-91349: Adjust default compression level to 6 (down from 9) in gzip and tarfile

It is the default level used by most compression tools and a
better tradeoff between speed and performance.

Co-authored-by: rmorotti <[email protected]>
Co-authored-by: Pieter Eendebak <[email protected]>
@hugovk hugovk mentioned this pull request Oct 22, 2026
[3.15] gh-91349: Update gzip docs and docstrings for the default compresslevel of 6 (GH-159439) #160096
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@merwok merwok merwok left review comments
@eendebakpt eendebakpt eendebakpt left review comments
@gpshead gpshead gpshead approved these changes
@ethanfurman ethanfurman Awaiting requested review from ethanfurman ethanfurman is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

3.15 bugs and security fixes

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@morotti @gpshead @merwok @hugovk @eendebakpt @emmatyping @rmmancom
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.