python vs awk for simple sysamin tasks

Steve Lamb grey at despair.dmiyu.org
Thu Jun 3 13:18:20 EDT 2004


On 2004-06-03, Roy Smith <roy at panix.com> wrote:
> You may be right that a python script would be faster.  The shell pipe 
> does make two passes over the data, not to mention all the pipe 
> overhead, and the binary -> ascii -> binary double conversion.

> But does it matter?  Probably not.  Groveling your way through a whole 
> file system is pretty inefficient any way you do it.  It's extremely 
> rare to find a sysadmin task where this kind of efficiency tweaking 
> matters.  As long as the overall process remains O(n), don't sweat it.

    I'm sorry but when I look at things like this I look at the case where
such things would be used a couple hundred thousand times.  Small
inefficiencies like multiple stat() passes and tons of system() calls pile up
fast and can baloon a run time from a managable "few hours" to well over a
day.

> To a certain extent, you're right, but the two examples given really 
> were effectively one liners.

    Yes, they were.  But combined it is no longer a one liner since at that
point one is storing the count value and doing something with it.  ;)

-- 
         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
       PGP Key: 8B6E99C5       | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------



More information about the Python-list mailing list