Title: os.path.dirsort() rather slow...? Post by: David H. on November 22, 2010, 01:34:36 pm FYI,
I was just doing some testing with the File Manipulation Functions using v2.21.10 on Windows. I used the sample function below to get a sorted directory listing of a network drive. The network drive has 78 directories and 185 files. With sorting disabled the timings were:- 1 2010-11-22 12:26:08.299 2 2010-11-22 12:26:08.299 3 2010-11-22 12:26:08.612 With sorting active:- 1 2010-11-22 12:29:32.711 2 2010-11-22 12:29:32.726 3 2010-11-22 12:29:47.426 Seems rather a long time to sort so few items... For comparison, a dir /os command returns a sorted list instantly. David Code
Title: Re: os.path.dirsort() rather slow...? Post by: Sebastien F. on November 23, 2010, 03:02:04 pm Hello David,
1) I wonder that you are still using 2.21, please move to 2.30 (ask support to help you). See this: https://4js.com/en/support/issue/?id=16458 => Not fixed in 2.21, fixed in 2.30. 2) os.Path.dirsort() is slow on Windows, this is a known problem, we must have a look. Seb Title: Re: os.path.dirsort() rather slow...? Post by: David H. on November 24, 2010, 01:35:00 pm Hi Seb,
RE: 1) Yes I had already noticed the bug with sorting on file times and that is was fixed in v2.30...! It is a common requirement for us to work with a subset of the files in a directory (i.e. "*.xml"). As a potential feature request it would be nice if a wildcard filter could be setup to alter the range of files returned by os.Path.dirNext(), i.e:- CALL os.Path.dirfmask(1+2+4) #filter file types CALL os.Path.filter("*.xml") # filter range of files returned CALL os.Path.dirsort("mtime",1) #sort the files by date modified LET handle = os.Path.diropen(path) etc Title: Re: os.path.dirsort() rather slow...? Post by: Sebastien F. on November 25, 2010, 10:50:43 am It is a common requirement for us to work with a subset of the files in a directory (i.e. "*.xml"). As a potential feature request it would be nice if a wildcard filter could be setup to alter the range of files returned by os.Path.dirNext(), i.e:- CALL os.Path.dirfmask(1+2+4) #filter file types CALL os.Path.filter("*.xml") # filter range of files returned CALL os.Path.dirsort("mtime",1) #sort the files by date modified LET handle = os.Path.diropen(path) etc I have created an enhancement record: #19081 Thanks for the idea. Seb Title: Re: os.path.dirsort() rather slow...? Post by: David H. on November 30, 2010, 12:06:31 pm On the subject of enhancements, a function to return in advance the count of files returned by dirNext() would be useful too...
Title: Re: os.path.dirsort() rather slow...? Post by: Sebastien F. on November 30, 2010, 04:35:41 pm 2) os.Path.dirsort() is slow on Windows, this is a known problem, we must have a look. Filed as bug #19114, we'll try to fix that for next 2.30 Maintenance Release. Seb |