Python 3 unbuffered IO

cjermain at gmail.com cjermain at gmail.com
Wed Sep 16 13:09:50 EDT 2015


What is the best way to determine if a file object is unbuffered?

In Python 3.4, if I open the file with buffering=0, I get a FileIO object.

>>> fh = open("tmp", "rb+", buffering=0)
>>> fh
<_io.FileIO name='tmp' mode='rb+'>

Is the FileIO object always unbuffered?

If I open it without buffering=0, I get a BufferedRandom.

>>> fh = open("tmp", "rb+")
>>> fh
<_io.BufferedRandom name='tmp'>

Should I just compare the file object class to determine buffering?

Ultimately, I'd like to determine when a file object is unbuffered to fix an issue in a CPython section of numpy.

Thanks for your help!



More information about the Python-list mailing list