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 — Use bytearray.take_bytes to speed up asyncio.streams · Issue #141863 · python/cpython

Use bytearray.take_bytes to speed up asyncio.streams #141863

New issue
Copy link
New issue
Copy link
Closed
Closed
Use bytearray.take_bytes to speed up asyncio.streams#141863
Copy link
Labels
performancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-asynciotype-featureA feature request or enhancementA feature request or enhancement

Description

@cmaloney
cmaloney
opened on Nov 23, 2025
Issue body actions

Feature or enhancement

Proposal:

Multiple codepaths in asyncio.streams operate on self._buffer (a bytearray) and then "take" (copy and delete bytes from original) when returning or passing them to other functions. That code pattern can be optimized with .take_bytes() added in gh-139871

Pyperformance:

tb_base.json
============

Performance version: 1.13.0
Python version: 3.15.0a2+ (64-bit) revision 227b9d326ec
Report on Linux-6.17.8-arch1-1-x86_64-with-glibc2.42
Number of logical CPUs: 32
Start date: 2025-11-22 16:18:13.127794
End date: 2025-11-22 16:18:41.207577

tb_asyncio.json
===============

Performance version: 1.13.0
Python version: 3.15.0a2+ (64-bit) revision 6982581e422
Report on Linux-6.17.8-arch1-1-x86_64-with-glibc2.42
Number of logical CPUs: 32
Start date: 2025-11-22 16:13:46.913998
End date: 2025-11-22 16:14:14.140152

### asyncio_tcp ###
Mean +- std dev: 169 ms +- 2 ms -> 143 ms +- 6 ms: 1.18x faster
Significant (t=18.89)

### asyncio_tcp_ssl ###
Mean +- std dev: 546 ms +- 8 ms -> 533 ms +- 6 ms: 1.02x faster
Significant (t=6.02)

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

  • gh-141863: Use bytearray.take_bytes in asyncio.streams #141864

Activity

  1. cmaloney
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Nov 23, 2025
  2. cmaloney
    added a commit that references this issue on Nov 23, 2025

    pythongh-141863: Use bytearray.take_bytes in asyncio.streams

    0b150fc
  3. StanFromIreland
    added
    performancePerformance or resource usagePerformance or resource usage
    topic-asyncio
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Nov 23, 2025
  4. github-project-automation
    added this to asyncioon Nov 23, 2025
  5. github-project-automation
    moved this to Todo in asyncioon Nov 23, 2025
  6. kumaraditya303
    added a commit that references this issue on Nov 24, 2025

    gh-141863: use `bytearray.take_bytes` in asyncio streams for better p…

    b484c32
  7. kumaraditya303
    closed this as completedon Nov 24, 2025
  8. github-project-automation
    moved this from Todo to Done in asyncioon Nov 24, 2025
  9. StanFromIreland
    added a commit that references this issue on Dec 6, 2025

    pythongh-141863: use `bytearray.take_bytes` in asyncio streams for be…

    962fd05
  10. ashm-dev
    added a commit that references this issue on Dec 8, 2025

    pythongh-141863: use `bytearray.take_bytes` in asyncio streams for be…

    1fd61d5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-asynciotype-featureA feature request or enhancementA feature request or enhancement

    Projects

    • asyncio
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — 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.