Mike Meyer wrote:
> On Thu, 11 Dec 2008 13:50:10 -0800
> Danek Duvall <[email protected]> wrote:
>
>   
>>>> line 239: Ew.  One: just use os.walk().  
>>>>         
>>> If I'm reading the manual pages correctly, I'd have to call
>>> os.path.walk(self.prefix, myfunc, None)
>>> then each time myfunc is called, I'd have to call os.listdir()
>>> to get a list of all the files in that directory, and for each one
>>> I'd then have to see if it's of type "f" (os.path.isfile()).
>>>       
>
> You're reading the wrong manual page. That's os.path.walk, he said
> os.walk, which is a generator, and hence easier to use in scripts:
>
> lines = []
> for dir, _, files in os.walk(self.prefix):
>    lines.extend(os.path.join(dir, file) for file in files)
>   

Ah. That's much nicer.

New webrev at:

  http://cr.opensolaris.org/~richb/pkg-5705-v4/

New timing for three runs are now:

$ time python check_install_scripts.py >/tmp/list.txt

real    0m3.530s
user    0m0.662s
sys     0m0.493s

$ time python check_install_scripts.py >/tmp/list.txt

real    0m1.788s
user    0m0.658s
sys     0m0.331s

$ time python check_install_scripts.py >/tmp/list.txt

real    0m1.790s
user    0m0.658s
sys     0m0.333s
$

Thanks.

_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

Reply via email to