[ftputil] Ftputil seems really slow to distinguish file and folders

Stefan Schwarzer sschwarzer at sschwarzer.net
Thu Apr 30 21:54:11 CEST 2009


Hello Nicola,

What I like about your reports is that you always provide
concrete examples with working test code. Great! :-)

On 2009-04-29 22:46, MailingList SVR wrote:
> I need to distinguish beetween file and folder, I'm using
> host.path.isdir and host.path.isfile but these seems really slow.
> 
> Here is an example code:
> 
> host=ftputil.FTPHost('ftp.nluug.nl','anonymous','pippo at pippo.com')
> folder='/vol/1/centoslinux/5.3/os/SRPMS/'
> lista=host.listdir(folder)
> 
> # host.listdir is fast, good!
>
> for l in lista:
>         print folder+l
>         print datetime.datetime.now()
>        #host.path.isdir and isfile are slow :-(
>         if host.path.isdir(folder+l):
>                 print 'dir:'
>                 print datetime.datetime.now()
>         if host.path.isfile(folder+l):
>                 print 'file:'
> 
> and this is the output:
> [...]

Running this with ftputil 2.4 on my computer takes about
25 minutes. When increasing the cache size to 2000, the code
runs in about 40 seconds. :)

For the details, please read this section of the ftputil
documentation:

http://ftputil.sschwarzer.net/trac/wiki/Documentation#local-caching-of-file-system-information

(context: the directory you work on has 1193 items in it, and
ftputil's default cache size is 1000)

Best regards,
Stefan


More information about the ftputil mailing list