[issue13882] PEP 410: Use decimal.Decimal type for timestamps
STINNER Victor
report at bugs.python.org
Mon Feb 13 01:23:13 CET 2012
STINNER Victor <victor.stinner at gmail.com> added the comment:
Here is the version 17 of my patch. This version is mostly complete and so can be reviewed. Summary of the patch:
- Add a _PyTime_t structure to store any timestamp in any resolution, universal structure used by all functions manipulating timestamps instead of C double to avoid loss of precision
- Add many functions to create timestamp (set _PyTime_t structure) or to get a timestamp in a specific format (int, float, Decimal, timeval or timespec structure, in milliseconds, etc.)
- Round to nearest with ties going away from zero (rounding method called "ROUND_HALF_UP" in Decimal)
- Functions creating timestamps get a new optional timestamp argument to specify the requested return type, e.g. time.time(timestamp=int) returns an int
- Functions getting timestamps argument now also support decimal.Decimal
- Raise an OverflowError instead of a ValueError if a timestamp cannot be stored in a C time_t type
The patch is huge, but as I wrote before, I will split it into smaller parts:
- Add _PyTime_t API
- Use the new API in the time module
- Use the new API in the os module
- etc.
Changes in the version 17 of my patch:
- tested on Linux 32/64 bits, OpenBSD 64 bits, FreeBSD 64 bits, Windows 64 bits
- fix portability issues (for various time_t and C long sizes)
----------
Added file: http://bugs.python.org/file24505/time_decimal-17.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13882>
_______________________________________
More information about the Python-bugs-list
mailing list