You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Operators on `Period`s are performed on the underlying femtosecond values.
@@ -108,12 +108,6 @@ Consequently, `Platform.default_clk_frequency()` is also deprecated and replaced
108
108
109
109
- Accepting a `numbers.Real` when we're converting from a number lets us pass in any standard suitable number type.
110
110
111
-
- When converting to a number, `fractions.Fraction` is a standard `numbers.Real` type that is guaranteed to represent any possible value exactly, and is convertible to `int` or `float`.
112
-
- Returning `int` would force a potentially undesirable truncation/rounding upon the user.
113
-
- Returning `float` would lose precision when the number of femtoseconds are larger than the significand.
114
-
-`decimal.Decimal` is decimal floating point and thus has the same issue as `float`.
115
-
-`.femtoseconds` returns `int` because that's a perfect representation and returning a fraction with a denominator of 1 adds no value.
116
-
117
111
- The supported set of operators are the ones that have meaningful and useful semantics:
118
112
- Comparing, adding and subtracting time periods makes sense.
119
113
- Multiplying a time period with or dividing it by a real number scales the time period.
@@ -127,6 +121,11 @@ Consequently, `Platform.default_clk_frequency()` is also deprecated and replaced
127
121
- Instead of named constructor arguments, we could use a classmethod for each SI prefix.
128
122
This was proposed in an earlier revision of this RFC.
129
123
124
+
- Instead of returning `float`, we could return `fractions.Fraction` to ensure no precision loss when the number of femtoseconds is larger than the `float` significand.
125
+
This was proposed in an earlier revision of this RFC.
126
+
- Rounding to integer femtoseconds is already lossy and a further precision loss from converting to a `float` is negligible in most real world use cases.
127
+
For any applications requiring an exact conversion of a `Period`, the `.femtoseconds` property is always exact.
0 commit comments