This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Closing a BufferedRandom calls lseek() mutliple times
Type: performance Stage: resolved
Components: IO Versions: Python 3.7
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: pitrou, serhiy.storchaka, vstinner
Priority: normal Keywords:

Created on 2017-05-02 12:17 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1386 closed vstinner, 2017-05-02 13:02
Messages (3)
msg292749 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-02 12:17
Given the following snippet:

    with open("x", "w+", encoding="utf-8") as fp:

Creating the TextIOWrapper object requires many syscall: see the issue #30228.

But I also noticed that *closing* such object also requires multiple lseek() syscalls, whereas the snippet doesn't read nor write anything.

Attached PR avoids lseek() if read and write buffers are empty.
msg292930 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-03 17:55
READAHEAD uses read_end, RAW_OFFSET uses raw_pos. Are you sure that if READAHEAD(self) is zero RAW_OFFSET(self) is zero too?
msg300145 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-11 00:09
I closed my PR, so I also close this issue.
Date User Action Args
2022-04-11 14:58:45adminsetgithub: 74415
2017-08-11 00:09:08vstinnersetstatus: open -> closed
resolution: rejected
messages: + msg300145

stage: resolved
2017-05-03 17:55:48serhiy.storchakasetmessages: + msg292930
2017-05-02 13:02:52vstinnersetpull_requests: + pull_request1493
2017-05-02 12:17:53vstinnercreate