High resolution time in python on a linux system
<p>This is a 2-part question and the first part is simple.  I'm trying to get the current time as a high resolution number, something easily done with the Time::HiRes module in perl.  I did find answers this questions elsewhere to use using time.time() in python.  The only thing is when I do this all I get as 2 significant digits and am wondering if I need to import something else or set something in my environment or what.  Look at this:</p>

<pre><code>&gt;&gt;&gt; import time
&gt;&gt;&gt; print time.time()
1326459121.68
</code></pre>

<p>My second question has to do with setitimer, which according to the docs says it will deliver alarms and the time can be specified as a floating point number.  Sounds exactly what I want.  In fact,  according to this - <a href="http://stackoverflow.com/questions/2292054/python-timer-mystery">python timer mystery</a> it looks pretty easy to use.  But when I make an exact copy of that example, I get this:</p>

<pre><code>[root@poker python]# ./signal.py
Traceback (most recent call last):
  File "./signal.py", line 10, in ?
    signal.setitimer(signal.ITIMER_REAL, 2, 2)
AttributeError: 'module' object has no attribute 'setitimer'
</code></pre>

<p>Perhaps part my the problem is that as a new python user I'm still not 'one with python' and perhaps am not understanding what the error message it trying to tell me.  Is it complaining that it can't find signal.setitimer OR is there something wrong with the attributes I'm passing?  I was wondering if it couldn't resolve signal.ITIMER_REAL and so tried calling it with a 0 just to see what would happen and now it's telling me:</p>

<pre><code>[root@poker python]# ./signal.py
Traceback (most recent call last):
  File "./signal.py", line 10, in ?
    signal.setitimer(0, 2, 2)
AttributeError: 'module' object has no attribute 'setitimer'
</code></pre>

<p>so I have to believe it is signal.setitmer itself that is having issues.</p>

<p>Aha!  I just figured out the problem by trying this on a VM with a newer version of python and it works just fine.  Looks like setitimer is not available with my version of python but how can I tell from the error message?  Shouldn't it be saying the module has no method?  Calling the missing method an attribute is pretty confusing.</p>

<p>Maybe that's just part of the learning curve.  Anyhow I thought I'd keep this second question in here so other might benefit, but I still am still stumped by what I can't get high resultion time from time.time() which still only reports in hundredths of a second even on this newer version of python.</p>
