How To Do It Faster?!?

andrea_gavana at tin.it andrea_gavana at tin.it
Thu Mar 31 21:21:56 CEST 2005


Hello max & NG,

>I don't quite understand what your program is doing. The user=a[18::20]
>looks really fragile/specific to a directory to me. 

I corrected it to user=a[18::5][:-2], it was my mistake. However, that command
is NOT specific to a particular directory. You can try to whatever directory
or net resource mounted on your system. It works.

>>> a=os.popen("dir /s /q /-c /a-d " + root).read().splitlines()

Mhm... have you tried this command on a BIG directory? On your C: drive
for example? I had to kill Python after having issued that command because
it ate up all my CPU (1GB) for a quite long time. There simply are too many
files/information to retrieve in a single command. 
In my first mail, I said I have to work with a BIG directory (more than
1 TB) and I need to retrieve information when they become available (I put
this info on a wxPython ListCtrl). This is why I have chosen os.walk() and
that command (that runs on a separate thread wrt the ListCtrl). 
It does NOT run faster than your command (probably my solution is slower),
but I can get information on every directory I scan, while with your command
I have to wait a long time to process the results, plus the user can not
interact with the results already found.

>To get a list containing files owned by a specific user, do something like:
>>> files=[line.split()[-1] for line in a if owner in line]

I will try this solution also.

Thanks NG for your useful suggestions.

Andrea.




More information about the Python-list mailing list