Title: Explore using PyBytesWriter API for compression libraries output buffers · Issue #139877 · python/cpython · GitHub
Open Graph Title: Explore using PyBytesWriter API for compression libraries output buffers · Issue #139877 · python/cpython
X Title: Explore using PyBytesWriter API for compression libraries output buffers · Issue #139877 · python/cpython
Description: Feature or enhancement The new PyBytesWriter() API is fast and easy to use. I expect it will bring a nice improvement both to maintainability and speed for compression output buffer management. I have some perf recordings showing that a ...
Open Graph Description: Feature or enhancement The new PyBytesWriter() API is fast and easy to use. I expect it will bring a nice improvement both to maintainability and speed for compression output buffer management. I h...
X Description: Feature or enhancement The new PyBytesWriter() API is fast and easy to use. I expect it will bring a nice improvement both to maintainability and speed for compression output buffer management. I h...
Opengraph URL: https://github.com/python/cpython/issues/139877
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Explore using PyBytesWriter API for compression libraries output buffers","articleBody":"# Feature or enhancement\n\nThe new `PyBytesWriter()` API is fast and easy to use. I expect it will bring a nice improvement both to maintainability and speed for compression output buffer management.\n\nI have some perf recordings showing that a large portion (>50%!) of time in decompression for a mix of data sizes (1K, 1M, 1G) is in `_BlocksOutputBuffer_Finish`, re-assembling the output buffer.\n\nI also made a very hacky modification to pycore_blocks_output_buffer.h to use `PyBytesWriter()` and found it greatly sped up decompression time:\n\nThe below two tests are operating on compressed enwiki content with zstd compression.\n| test | main | PyBytesWriter() |\n|--------|--------|--------|\n| decompress 1M | 2.15ms | 1.65ms |\n| decompress 1G | 2.2s | 1.73s |\n\nThose are 25-30% speedups!\n\nI think this is enough to motivate a refactor of this code to use `PyBytesWriter()` and benchmark against the current implementation across compression modules and data sizes.\n\ncc @vstinner for viz\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-139976\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/emmatyping","@type":"Person","name":"emmatyping"},"datePublished":"2025-10-10T00:19:08Z","url":"https://github.com/python/cpython/issues/139877"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b32860ea-be45-d163-964c-97d7e4a184e0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9B9A:1050BD:14AF633:1B5F7A3:6B01F9FE |
| html-safe-nonce | 201b8262fce391bbff2e0338556e169a2290ee8ca054b0163a4df7f065d68619 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QjlBOjEwNTBCRDoxNEFGNjMzOjFCNUY3QTM6NkIwMUY5RkUiLCJ2aXNpdG9yX2lkIjoiMTM0MjkxNjYyMTc2MDU5MjM4MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | aeeb82553d8e3c1fbe730f0331c4af1016d07263374eb6108bf67f7a0b9d6849 |
| hovercard-subject-tag | issue:3500964691 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/139877/issue_layout |
| twitter:image | https://opengraph.githubassets.com/70dd524b1217baf2cb83ec5574c3aab55bb29497eba38a6c3d0fa1c34aac18f6/python/cpython/issues/139877 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/70dd524b1217baf2cb83ec5574c3aab55bb29497eba38a6c3d0fa1c34aac18f6/python/cpython/issues/139877 |
| og:image:alt | Feature or enhancement The new PyBytesWriter() API is fast and easy to use. I expect it will bring a nice improvement both to maintainability and speed for compression output buffer management. I h... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | emmatyping |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width