FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-129813, PEP 782: Use PyBytesWriter in posix extension by vstinner · Pull Request #138829 · python/cpython · GitHub

Repository navigation

gh-129813, PEP 782: Use PyBytesWriter in posix extension - #138829

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:pybyteswriter_posix
Sep 13, 2025
Merged

vstinner merged 1 commit into
python:mainfrom
vstinner:pybyteswriter_posix

Conversation

vstinner commented Sep 12, 2025 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize() with the new public PyBytesWriter API.

Replace PyBytes_FromStringAndSize(NULL, size) and _PyBytes_Resize()
with the new public PyBytesWriter API.

Copy link
Copy Markdown
Member Author

I ran a microbenchmark on os.read():

import pyperf
import os

file = open(__file__, "rb", 0)
fd = file.fileno()
def func():
    os.lseek(fd, 0, os.SEEK_SET)
    for _ in range(100):
        os.read(fd, 1)

runner = pyperf.Runner()
runner.bench_func('bench', func)

file.close()

Result: Mean +- std dev: [ref] 34.0 us +- 0.3 us -> [pep782] 33.6 us +- 0.3 us: 1.01x faster

So this change has no significant impact on the performance.

vstinner merged commit af386fd into python:main Sep 13, 2025
47 checks passed
vstinner deleted the pybyteswriter_posix branch September 13, 2025 16:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL