[issue30229] Closing a BufferedRandom calls lseek() mutliple times

STINNER Victor report at bugs.python.org
Tue May 2 08:17:53 EDT 2017


New submission from STINNER Victor:

Given the following snippet:

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

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.

----------
components: IO
messages: 292749
nosy: haypo, pitrou, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Closing a BufferedRandom calls lseek() mutliple times
type: performance
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30229>
_______________________________________


More information about the Python-bugs-list mailing list