Daniel Jewell <danieljew...@gmail.com> added the comment:

To add something additional here:

The current documentation for tempfile.SpooledTemporaryFile indicates "This 
function operates exactly as TemporaryFile() does, except that data is spooled 
in memory until the file size exceeds max_size[...]" (see 
https://docs.python.org/3/library/tempfile.html)

Except that SpooledTemporaryFile *doesn't* act _exactly_ like TemporaryFile() - 
as documented here. TemporaryFile() returns an "_io.BufferedRandom" which 
implements all of the expected "file-like" goodies - like [.readable, 
.seekable, ...etc]. SpooledTemporaryFile does not.

In comparing to the 2.x docs, the text for SpooledTemporaryFile() appears to be 
identical or nearly identical to the 3.8.x current docs. This goes in line with 
what has already been discussed here.

At a _very minimum_ the documentation should be updated to reflect the current 
differences between TemporaryFile() and SpooledTemporaryFile(). 

Perhaps an easier change would be to extend TemporaryFile() to have a parameter 
that enables functionality similar to SpooledTemporaryFile? Namely, 
*memory-only* storage up to a max_size? Or perhaps there is an alternate 
solution that already exists? 

Ultimately, the functionality that appears to be missing is to be able to 
easily create a file-like object backed primarily by memory for reading/writing 
data ... (i.e. one 100% compatible with 'the usual' file objects returned by 
open()...)

----------
nosy: +danieljewell

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue26175>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to