<div dir="ltr">Oops. That isn't the TOTAL microseconds, but just the microseconds portion. Sorry for the confusion.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 13, 2019 at 9:23 PM Henry Chen <<a href="mailto:tahafut@gmail.com">tahafut@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Looks like timedelta has a microseconds property. Would this work for your needs?</div><div dir="ltr"><br><div><div>In [12]: d</div><div>Out[12]: datetime.timedelta(0, 3, 398407)</div><div><br></div><div>In [13]: d.microseconds</div><div>Out[13]: 398407</div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 13, 2019 at 9:08 PM Richard Belleville via Python-Dev <<a href="mailto:python-dev@python.org" target="_blank">python-dev@python.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>In a recent code review, the following snippet was called out as reinventing the</div><div>wheel:</div><div><br></div><div>_MICROSECONDS_PER_SECOND = 1000000</div><div><br></div><div><br></div><div>def _timedelta_to_microseconds(delta):</div><div>  return int(delta.total_seconds() * _MICROSECONDS_PER_SECOND)</div><div><br></div><div><br></div><div>The reviewer thought that there must already exist a standard library function</div><div>that fulfills this functionality. After we had both satisfied ourselves that we</div><div>hadn't simply missed something in the documentation, we decided that we had</div><div>better raise the issue with a wider audience.</div><div><br></div><div>Does this functionality already exist within the standard library? If not, would</div><div>a datetime.timedelta.total_microseconds function be a reasonable addition? I</div><div>would be happy to submit a patch for such a thing.</div><div><br></div><div>Richard Belleville</div></div></div>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/tahafut%40gmail.com" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/tahafut%40gmail.com</a><br>
</blockquote></div>
</blockquote></div>