#35572: Improve performance replacing os.listdir() with os.scandir()
-------------------------------------+-------------------------------------
Reporter: Paolo Melchiorre | Owner: Marcus
Type: | Vinicius Araujo
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: dev
Severity: Normal | Resolution:
Keywords: scandir listdir | Triage Stage: Accepted
python os |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Natalia Bidart):
After reviewing this ticket, the relevant documentation, and the PR, I
remain unconvinced of the benefits of this change. Given Tim's question
and answer (specifically, that only `manage_translations.py` requires file
type or file attribute information) the proposed change seems to add an
extra level of indentation to the code without a clear benefit.
Basic performance tests show only minimal improvements. In accordance with
our [
https://docs.djangoproject.com/en/dev/internals/contributing/bugs-
and-features/#requesting-performance-optimizations current docs for
requesting performance optimizations] I think we need to mark this as
`wontfix` until a clear and substantial performance gain is demonstrated.
The risk of breaking systems that rely on `os.listdir` (for example, via
monkeypatching) outweighs the potential unproven benefits.
--
Ticket URL: <
https://code.djangoproject.com/ticket/35572#comment:10>