I'm trying to speed up the processing time of a script, which in certain configurations may have a lot of output dumped to the console (file=stdout) via print(). Is Python's print() function blocking or non-blocking? I've not able able to find an adequate answer for this in the documentation.
I'm running Linux 4.18.0-486.el8.x86_64 GNU/Linux.
This is the implementation of
print()in python which is essentially a write function with various formatting tasks.https://github.com/python/cpython/blob/v3.11.2/Python/bltinmodule.c#L1986
It is possible to turn on non blocking file writes on unix, however, turning on non-blocking mode has no visible effect for regular files
From what I understand write tasks fill a buffer [cached] and are written to disk after.
Furthermore on POSIX,