PEP 410: Update for Nick's remarks
This commit is contained in:
parent
b8925c8605
commit
d089c806d4
39
pep-0410.txt
39
pep-0410.txt
|
@ -42,8 +42,12 @@ bigger than 2^24 seconds (194 days: 1970-07-14 for an Epoch timestamp).
|
|||
Specification
|
||||
=============
|
||||
|
||||
Add decimal.Decimal as a new type for timestamps. Add a *timestamp* optional
|
||||
argument to:
|
||||
Add decimal.Decimal as a new type for timestamps. Decimal supports any
|
||||
timestamp resolution, support arithmetic operations and is comparable.
|
||||
Functions getting float inputs support directly Decimal, Decimal is converted
|
||||
implicitly to float, even if the conversion may lose precision.
|
||||
|
||||
Add a *timestamp* optional argument to:
|
||||
|
||||
* os module: fstat(), fstatat(), lstat() and stat()
|
||||
* time module: clock(), clock_gettime(), clock_getres(), time() and
|
||||
|
@ -66,6 +70,10 @@ precision) in functions having timestamp arguments:
|
|||
|
||||
The os.stat_float_times() is deprecated: use timestamp=int argument instead.
|
||||
|
||||
.. note::
|
||||
The decimal module is implemented in Python and is slow, but there is a C
|
||||
reimplementation which is almost ready for inclusion in CPython.
|
||||
|
||||
|
||||
Backwards Compatibility
|
||||
=======================
|
||||
|
@ -124,6 +132,8 @@ datetime.datetime has issues:
|
|||
duplicate hour of switching from DST to normal time
|
||||
- time zone support is flaky-to-nonexistent in the datetime module
|
||||
|
||||
datetime.datetime is also more complex than a simple number.
|
||||
|
||||
datetime.timedelta
|
||||
------------------
|
||||
|
||||
|
@ -135,18 +145,7 @@ is more complex than a simple number and is not accepted by functions getting
|
|||
timestamp inputs.
|
||||
|
||||
|
||||
decimal.Decimal
|
||||
---------------
|
||||
|
||||
Decimal has an arbitrary precision, support arithmetic operations, is
|
||||
comparable. Functions getting float inputs support directly Decimal, Decimal is
|
||||
converted implicitly to float, even if the conversion may lose precision.
|
||||
|
||||
Using Decimal by default would cause bootstrap issue because the module is
|
||||
implemented in Python, but using Decimal by default was not considered.
|
||||
|
||||
The decimal module is implemented in Python and is slow, but there is a C
|
||||
reimplementation which is almost ready for inclusion in CPython.
|
||||
.. _tuple-integers:
|
||||
|
||||
Tuple of integers
|
||||
-----------------
|
||||
|
@ -215,6 +214,14 @@ the callback has to be decided once and cannot be changed later. For example,
|
|||
adding a timezone or the absolution start of the timestamp (e.g. Epoch or
|
||||
unspecified start for monotonic clocks) would break the API.
|
||||
|
||||
The protocol proposition was as being excessive given the requirements, but
|
||||
that the specific syntax proposed (time.time(timestamp=type)) allows this to be
|
||||
introduced later if compelling use cases are discovered.
|
||||
|
||||
.. note::
|
||||
Other formats can also be used instead of a fraction: see the `Tuple of integers
|
||||
<tuple-integers>`_ section
|
||||
|
||||
Add new fields to os.stat
|
||||
-------------------------
|
||||
|
||||
|
@ -233,6 +240,10 @@ Add a boolean argument
|
|||
Because we only need one new type, decimal.Decimal, a simple boolean flag
|
||||
can be added. For example, time.time(decimal=True) or time.time(hires=True).
|
||||
|
||||
The boolean argument API was rejected because it is not "pythonic". Changing
|
||||
the return type with a parameter value is preferred over a boolean parameter (a
|
||||
flag).
|
||||
|
||||
Add new functions
|
||||
-----------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue