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.

classification
Title: Import Long Load
Type: performance Stage: resolved
Components: Unicode Versions: Python 3.6
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Evgeniy Mischuk, ezio.melotti, matrixise, paul.moore, steve.dower, tim.golden, vstinner, zach.ware
Priority: normal Keywords: patch

Created on 2019-09-13 16:53 by Evgeniy Mischuk, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 16117 closed Evgeniy Mischuk, 2019-09-13 16:53
PR 16120 closed python-dev, 2019-09-13 17:27
Messages (4)
msg352365 - (view) Author: Evgeniy Mischuk (Evgeniy Mischuk) Date: 2019-09-13 16:53
for in TMP_MAX dont break and always continue
msg352570 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2019-09-16 18:57
I close the issue because there is no discussion :/
msg352571 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2019-09-16 18:57
and related to 3.6 (security)
msg352580 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-16 20:08
tempfile uses a low number of random bits per filename, so collision is "likely". Two Python processes might attempt to create the same temporary file "at the same time". Maybe not two processes, but two Python threads.

Rather than writing complex locking mechanism, "for seq in range(TMP_MAX):" retries. While one collision is "likely", TMP_MAX is less likely, especially if TMP_MAX is big.

On my Linux, I get:

pvstinner@apu$ python3
Python 3.7.4 (default, Jul  9 2019, 16:32:37) 
>>> import posix
>>> posix.TMP_MAX
238328

Removing the loop introduces a race condition. You tagged this issue as "performance": well, in Python we don't accept optimizations which make Python "not correct". Correctness matters more than performance.

If tempfile is critical for your application performance, you can easily copy tempfile.py and adapt it for your needs ;-)

--

Well, as Stéphane wrote: you need to eloborate the rationale for your change.
History
Date User Action Args
2022-04-11 14:59:20adminsetgithub: 82343
2019-09-16 20:08:02vstinnersetmessages: + msg352580
2019-09-16 18:57:50matrixisesetmessages: + msg352571
2019-09-16 18:57:33matrixisesetstatus: open -> closed

components: + Unicode, - Windows

nosy: + ezio.melotti, matrixise, vstinner
messages: + msg352570
resolution: rejected
stage: patch review -> resolved
2019-09-13 17:27:33python-devsetkeywords: + patch
stage: patch review
pull_requests: + pull_request15736
2019-09-13 16:53:57Evgeniy Mischukcreate