something better than time.time()?
<p>My team and I are designing a project which requires the detection of rising edge of a square wave and then storing the time using time.time() in a variable.If a same square wave is given to 3 different pins of RPi,and event detection is applied on each pin,theoretically,they should occur at the same time,but they have a delay which causes a difference in phase too (we are calculating phase from time).
We concluded that time.time() is a slow function.
Can anyone please help me as to which function to use to get SOC more precise than time.time()?
Or please provide me with the programming behind the function time.time().
I'll be really thankful. </p>

<p><code>time.time</code> uses <code>gettimeofday</code> on platforms that support it. That means its resolution is in microseconds.</p>

<p>You might try using <code>time.clock_gettime(time.CLOCK_REALTIME)</code> which provides nanosecond resolution (assuming the underlying hardware/OS provides that). The result still gets converted to floating point as with <code>time.time</code>.</p>

<p>It's also possible to load up the <code>libc</code> shared object and invoke the native <code>clock_gettime</code> using the <code>ctypes</code> module. In that way, you could obtain access to the actual nanosecond count provided by the OS. (Using <code>ctypes</code> has a fairly steep learning curve though.)</p>

python time soc