ID EN
Tempfile

SpooledTemporaryFile

Python 3.11

This class operates exactly as TemporaryFile() does, except that data is spooled in memory until the file size exceeds max_size, or until the file’s fileno() method is called, at which point the contents are written to disk and operation proceeds as with TemporaryFile().

Syntax

PYTHON
class tempfile.SpooledTemporaryFile(max_size=0, mode='w+b', buffering=-1, encoding=None, newline=None, suffix=None, prefix=None, dir=None, *, errors=None)

See Also

TemporaryFile() fileno() TemporaryFile() io.BytesIO io.TextIOWrapper rollover() with io.BufferedIOBase