This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author graham.coster
Recipients Gary Fernie, James Hennessy, graham.coster, martin.panter, methane, nubirstein, r.david.murray, serhiy.storchaka, terry.reedy
Date 2019-11-26.01:48:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <23A63731-1232-4D0F-A8C7-9FAA73A7A814@yahoo.co.uk>
In-reply-to <1574649447.62.0.52476229188.issue38625@roundup.psfhosted.org>
Content
This may be a silly question, however, does SpooledTemporaryFile need to exist at all?

From some testing on macOS, SpooledTemporaryFile appeared to never have a performance advantage over OS file caching, but with max_size greater than 4GB, it was a significant disadvantage.   

I found that the macOS built-in file cache was increasing in size as I wrote bigger TemporaryFile files, up to some limit the OS had decided. So, it seems the OS is automatically doing the same job as SpooledTemporaryFile.  Once the OS decided to write to disk, there was no sudden hit to performance, it just slowed down.

However, when SpooledTemporaryFile rolled-over large max_size files, there was a temporary big hit to performance, which then became a consistent slow down the same as TemporaryFile.

A big issue came with very large SpooledTemporaryFile  max_sizes hogging RAM and causing the OS to start swapping all processes.  This caused a huge performance hit to my program and the system as a whole. Once my program did finish, it took the system considerable time to reclaim swap.

I’m guessing SpooledTemporaryFile may have benefits on light weight embedded OSes that have no, or poor, file caching.  However, tuning the max_size to work with embedded systems’ limited RAM could be tricky for developers and would be hardware dependent. So, perhaps leaving file caching to operating systems is actually a better, and safer, option than offering it in Python?

If there are no benefits to SpooledTemporaryFile, should it be deprecated? If so, as it is phasesd out, could it be patched to be a TemporaryFile wrapper, with no rollover functionality?

> On 25 Nov 2019, at 1:37 pm, Inada Naoki <report@bugs.python.org> wrote:
> 
> 
> Inada Naoki <songofacandy@gmail.com> added the comment:
> 
> SpooledTemporaryFile has very serious bug which causes data corruption (#26730).  Please don't use it with text mode until it is fixed.
> 
> ----------
> 
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue38625>
> _______________________________________
History
Date User Action Args
2019-11-26 01:48:04graham.costersetrecipients: + graham.coster, terry.reedy, r.david.murray, methane, martin.panter, serhiy.storchaka, Gary Fernie, James Hennessy, nubirstein
2019-11-26 01:48:04graham.costerlinkissue38625 messages
2019-11-26 01:48:03graham.costercreate