Rif: Re: How To Do It Faster?!?

A

andrea.gavana

Hello Lazslo & NG,
You can use the stat module to get attributes like last modification
date, uid, gid etc. The documentation of the stat module has a nice
example. Probably it will be faster because you are running an external
program (well, "dir" may be resident but still the OS needs to create a
new shell and interpret the parameters on every invocation).

Unfortunately, on Windows it does not seem to work very well:

0

I don't think my user ID is 0...

While with the OS dos command I get:

userid: \\ENI\ag12905

Am I missing something on the stat module? I'm running Python 2.3.4.

Thanks a lot.

Andrea.
 
D

Diez B. Roggisch

Am I missing something on the stat module? I'm running Python 2.3.4.

Yes, you are missing that this is more unix-like. It seems to work in a
certain degree on windows - but as the user-model between unix and windows
is considerably different, you found a not-so-well working part.

I don't think that your code could be much faster at all - the limits are
not so much within python than windows itself. The only thing I can think
of is to use python-win32 to make the calls that dir with your various
options does itself. That would maybe save you the additional overhead of
creating a string representation (done by dir) and parsing that - but I
doubt the performance gain justifies the means.
 
P

Peter Hansen

Unfortunately, on Windows it does not seem to work very well:
0

I don't think my user ID is 0...

While with the OS dos command I get:

userid: \\ENI\ag12905

I would recommend using the pywin32 support that almost
certainly exists for getting the owner of a file.

On the other hand, I'm not familiar with the Windows
API in question, but either somebody else will point
you to it, or a search on msdn.com would find it for
you.

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top