title: Microsecond accurate timestamp in python?
body: <p>Is there a way to maintain microsecond accuracy when converting a Python datetime to a timestamp?</p>
  
  <pre><code>&gt;&gt;&gt; import datetime
  &gt;&gt;&gt; d1 = datetime.datetime(2013,7,31,9,13,8,829)
  &gt;&gt;&gt; import time
  &gt;&gt;&gt; d1_ts = time.mktime(d1.timetuple())
  &gt;&gt;&gt; d1
  datetime.datetime(2013, 7, 31, 9, 13, 8, 829)
  &gt;&gt;&gt; d1_ts
  1375279988.0
  &gt;&gt;&gt; d1.fromtimestamp(d1_ts)
  datetime.datetime(2013, 7, 31, 9, 13, 8)
  </code></pre>
  
  <p>I lose that <code>.829</code> on the conversion. This is rather important, because I have start and end timestamps that I need to step through at set intervals (with sub-second steps) to gather data from some sensors. </p>
  
  <p>Eventually it will be used in a function similar to this:</p>
  
  <pre><code>from scipy import arange
  sample_time = 0.02
  for i in arange(d1_ts, d2_ts, sample_time):
      # do stuff
  </code></pre>
  
  <p>With a <code>sample_time</code> that small, the mircoseconds are important.</p>