terminalwriter: don't flush implicitly; add explicit flushes

Flushing on every write is somewhat expensive.

Rely on line buffering instead (if line buffering for stdout is
disabled, there must be some reason...), and add explicit flushes when
not outputting lines.

This is how regular `print()` e.g. work so should be familiar.
This commit is contained in:
Ran Benita
2020-04-29 17:58:33 +03:00
parent d9b43647b7
commit 1bc4170e63
5 changed files with 22 additions and 9 deletions

View File

@@ -1424,7 +1424,7 @@ def _showfixtures_main(config, session):
def write_docstring(tw: TerminalWriter, doc: str, indent: str = " ") -> None:
for line in doc.split("\n"):
tw.write(indent + line + "\n")
tw.line(indent + line)
class Function(PyobjMixin, nodes.Item):