[Python-Dev] datetime.timedelta total_microseconds

Richard Belleville rbellevi at google.com
Thu Feb 14 00:05:54 EST 2019

In a recent code review, the following snippet was called out as
reinventing the


def _timedelta_to_microseconds(delta):
  return int(delta.total_seconds() * _MICROSECONDS_PER_SECOND)

The reviewer thought that there must already exist a standard library
that fulfills this functionality. After we had both satisfied ourselves
that we
hadn't simply missed something in the documentation, we decided that we had
better raise the issue with a wider audience.

Does this functionality already exist within the standard library? If not,
a datetime.timedelta.total_microseconds function be a reasonable addition? I
would be happy to submit a patch for such a thing.

Richard Belleville
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20190213/1586f59c/attachment.html>

More information about the Python-Dev mailing list