[Python-Dev] datetime.timedelta total_microseconds

Richard Belleville rbellevi at google.com
Wed Feb 27 18:04:45 EST 2019


Sorry for the slow response.

Timedelta division is quite a nice solution to the problem. However, since
we're maintaining a python version agnostic library at least until 2020, we
need a solution that works in python 2 as well.

For the moment, we've left the code as in the original snippet.

Richard Belleville

On Wed, Feb 27, 2019 at 2:56 PM Chris Barker <chris.barker at noaa.gov> wrote:

> Did we ever hear back from the OP as to whether they were using py2 or 3?
>
> If they were unable to find timedelta division in py3 -- that's a pretty
> good case that we need something else.
>
>
> The OP:
> """
> On Wed, Feb 13, 2019 at 9:10 PM Richard Belleville via Python-Dev <
> python-dev at python.org> wrote:
>
>> 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.
>>
> """
>
> -CHB
>
> --
>
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR&R            (206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115       (206) 526-6317   main reception
>
> Chris.Barker at noaa.gov
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20190227/3b150560/attachment.html>


More information about the Python-Dev mailing list