You could specify the return value type annotations in the docstring of a
convert()/to_unit() method, or for each to_unit() method. Are they all
floats?

div and floordiv are not going away. Without reading the docs, I, too,
wouldn't have guessed that division by the desired unit is the correct way.

In terms of performance, a convert()/to_unit() method must do either a hash
lookup or multiple comparisons to present a more useful exception  than
that returned by initializing timedelta with something like nanoseconds=.

FWIW, astropy.time.TimeDelta supports sub-nanosecond precision and has a
.to() method for changing units/quantities.
http://docs.astropy.org/en/stable/time/#time-deltas

> The TimeDelta class is derived from the Time class and shares many of its
properties. One difference is that the time scale has to be one for which
one day is exactly 86400 seconds. Hence, the scale cannot be UTC.
>
> The available time formats are:
>
> Format     Class
> sec            TimeDeltaSec
> jd              TimeDeltaJD
> datetime  TimeDeltaDatetime

http://docs.astropy.org/en/stable/api/astropy.time.TimeDelta.html#astropy.time.TimeDelta

http://docs.astropy.org/en/stable/_modules/astropy/time/core.html#TimeDelta.to


On Thursday, February 28, 2019, Alexander Belopolsky <
alexander.belopol...@gmail.com> wrote:

> > while "some_var / some_other_var" could be doing anything.
>
> "At an elementary level the division of two natural numbers is – among
> other possible interpretations – the process of calculating the number of
> times one number is contained within another one."
>
> -- <https://en.wikipedia.org/wiki/Division_(mathematics)>
>
> The process of figuring out how many seconds fit into a given interval is
> called division by a second.
>
> I am afraid people who get confused by timedelta / timedelta division know
> too much about Python where / can indeed mean anything including e.g.
> joining filesystem paths.
>
_______________________________________________
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

Reply via email to