Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#29689 closed Cleanup/optimization (fixed)

Improve performance of FileSystemStorage.listdir() and FilePathField with os.scandir()

Reported by: Federico Bond Owned by: Federico Bond
Component: File uploads/storage Version: 2.1
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

Now that the minimum supported version is Python 3.5, we can replace os.listdir() with os.scandir() in FileSystemStorage.listdir() and FilePathField.__init__() to eliminate extra syscalls within the loops for improved performance.

Change History (6)

comment:1 by Federico Bond, 6 years ago

Owner: changed from nobody to Federico Bond

comment:2 by Federico Bond, 6 years ago

Has patch: set
Last edited 6 years ago by Tim Graham (previous) (diff)

comment:3 by Claude Paroz, 6 years ago

Patch needs improvement: set
Triage Stage: UnreviewedAccepted

comment:4 by Tim Graham, 6 years ago

Description: modified (diff)
Patch needs improvement: unset
Summary: Replace os.listdir with os.scandir in FileSystemStorage.listdirImprove performance of FileSystemStorage.listdir() and FilePathField with os.scandir()
Triage Stage: AcceptedReady for checkin

comment:5 by Tim Graham <timograham@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In a0ca4b56:

Fixed #29689 -- Improved performance of FileSystemStorage.listdir() and FilePathField with os.scandir().

comment:6 by Tim Graham <timograham@…>, 6 years ago

In 54b33145:

Refs #29689 -- Moved FilePathField choices sorting outside the loop.

Note: See TracTickets for help on using tickets.
Back to Top