Python3 datetime negative number
Question: I am trying to time a the run time of a function using datatime.now() and
subtracting their differences to get a floating point number of seconds.

    
    
    tStart = datetime.now()
    
    *function*
    
    tEnd = datetime.now()
    
    # microseconds for more precision then convert to seconds
    time = tEnd.microsecond - tStart.microsecond
    print(listLength, "\t", '{0:.6f}'.format(time/1000000))
    

Example Error:

    
    
    3250    0.043427
    3500    -0.940100
    3750    0.075566
    

Am I wrong for assuming that I can convert back to normal seconds with a
standard conversion? Is there a better way of doing this? I tried using
seconds but it only gets to hundredths of a second precision so I don't get
the 6 decimal digits I need.


Answer: If you just want to calculate the offset in seconds between two dates, the
_time_ module may be more what you are looking for. It expresses dates in
seconds since the UNIX epoch, so subtracting two dates gives natively a result
in seconds :

    
    
    import time
    tStart = time.time()
    *some code*
    print time.time() - tStart
    

