Python argument -u

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

Norbert Raimund Leisner
Posts: 1643
Joined: Tue May 20, 2008 4:57 pm
Location: Augsburg - Germany

Python argument -u

Post by Norbert Raimund Leisner »

Hello,

somebody wants to know : what is the meaning of python -u generally (in combination of a batch file)?

Could it be a connection between the Python.exe (Windows) and the commandline-parameter of an engine for an interface like Arena?

two examples are:
Shatranj https://github.com/stannous/shatranj
batch-file: python -u shatranj.py -xboard

Sunfish https://github.com/thomasahle/sunfish
batch-file: python -u xboard.py

Best wishes,
Norbert
abulmo2
Posts: 433
Joined: Fri Dec 16, 2016 11:04 am
Location: France
Full name: Richard Delorme

Re: Python argument -u

Post by abulmo2 »

According to manpage:

Code: Select all

- u  Force stdin, stdout and stderr to be totally unbuffered.  On systems where it matters, also put stdin, stdout and stderr in binary mode.  Note that there is internal buffering in xreadlines(), readlines() and file-object iterators ("for line in sys.stdin")  which is not influenced by this option. To work around this, you will want to use "sys.stdin.readline()" inside a "while 1:" loop.
So the -u command is necessary for the engine to read each (uci or cecp) command line by line, otherwise it will stay stuck until the buffer is full.
Richard Delorme