This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author exarkun
Recipients exarkun, pmolina
Date 2009-07-23.18:35:00
SpamBayes Score 1.0148416e-05
Marked as misclassified No
Message-id <1248374102.09.0.57824528345.issue6554@psf.upfronthosting.co.za>
In-reply-to
Content
For what it's worth, here are some timings from my system.  First,
os.kill without raising an exception:

exarkun@boson:~$ python -m timeit -s 'import os; pid = os.getpid()' '
os.kill(pid, 0)
'
1000000 loops, best of 3: 0.413 usec per loop
exarkun@boson:~$ 

Next, os.kill without raising an exception, but with exception handling:

exarkun@boson:~$ python -m timeit -s 'import os; pid = os.getpid()' '
> try:
>     os.kill(pid, 0)
> except OSError, e:
>     pass
> '
1000000 loops, best of 3: 0.42 usec per loop

Finally, os.kill with exception handling and raising an exception:

exarkun@boson:~$ python -m timeit -s 'import os; pid = os.getpid()' '
try:
    os.kill(pid + 1, 0)
except OSError, e:
    pass
'
100000 loops, best of 3: 2.58 usec per loop

The slowest case is almost 7x slower than the fastest case.  However,
this is only triggered when os.kill raises an exception (ie, if the pid
does exist, it's still fast).  Plus, this "slow" case still only takes
two and a half microseconds.  That's pretty fast.
History
Date User Action Args
2009-07-23 18:35:02exarkunsetrecipients: + exarkun, pmolina
2009-07-23 18:35:02exarkunsetmessageid: <1248374102.09.0.57824528345.issue6554@psf.upfronthosting.co.za>
2009-07-23 18:35:00exarkunlinkissue6554 messages
2009-07-23 18:35:00exarkuncreate