In a recent code review, the following snippet was called out as reinventing the wheel:
_MICROSECONDS_PER_SECOND = 1000000 def _timedelta_to_microseconds(delta): return int(delta.total_seconds() * _MICROSECONDS_PER_SECOND) The reviewer thought that there must already exist a standard library function 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, would a datetime.timedelta.total_microseconds function be a reasonable addition? I would be happy to submit a patch for such a thing. Richard Belleville
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com