This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年03月03日 00:10 by vstinner, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| pytime.patch | vstinner, 2012年03月03日 00:10 | review | ||
| Messages (9) | |||
|---|---|---|---|
| msg154811 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2012年03月03日 00:10 | |
There are various ways to convert a Python int/float to a C time_t, timeval or timespec structure. Attached patch factorize code by adding functions to convert a Python object to a C type (time_t, timeval or timespec). My patch changes how datetime rounds microsecond: round towards zero instead of rounding to nearest with ties going away from zero. I chose this rounding method because it is the method used by int(float) and int(time.time()) is a common in programs (more than round(time.time()). Rounding towards zero avoids also producing timestamps in the future. On overflow, an OverflowError is now raises instead of a ValueError. I prefer OverflowError over ValueError because it is an implementation detail. For example, time_t is 32 bits on Linux 32 bits, 64 bits on Linux 64 bits or on Windows (32 or 64 bits). PyTime_ObjectToXXX() functions are part of Python and so can be used by the posix, time, datetime and select modules. The patch removes _time.c, _time.h and timefunc.h because these files were only used for one function (_PyTime_DoubleToTime_t) which is no more used and it required to link a module to _time.c to get this function. -- If it is a problem to replace ValueError with OverflowError for backward compatibility, it is easy to adapt the patch to raise ValueError instead. timedelta*float and timedelta/float rounding method may also be changed. |
|||
| msg154984 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2012年03月05日 22:41 | |
Alexander: No complain if I remove _time.c? |
|||
| msg155600 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年03月13日 12:38 | |
New changeset 1e9cc1a03365 by Victor Stinner in branch 'default': Close #14180: Factorize code to convert a number of seconds to time_t, timeval or timespec http://hg.python.org/cpython/rev/1e9cc1a03365 |
|||
| msg155601 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年03月13日 12:50 | |
New changeset ed73006bac42 by Victor Stinner in branch 'default': Issue #14180: Remove commented code http://hg.python.org/cpython/rev/ed73006bac42 |
|||
| msg155616 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年03月13日 14:31 | |
New changeset 1eaf6e899f02 by Victor Stinner in branch 'default': Issue #14180: Fix select.select() compilation on BSD and a typo in kqueue_queue_control() http://hg.python.org/cpython/rev/1eaf6e899f02 |
|||
| msg155625 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年03月13日 15:25 | |
New changeset cb1c877a27f2 by Victor Stinner in branch 'default': Issue #14180: Fix another typo in kqueue_queue_control() http://hg.python.org/cpython/rev/cb1c877a27f2 |
|||
| msg155631 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年03月13日 16:42 | |
New changeset 760cf150bb99 by Victor Stinner in branch 'default': Issue #14180: Fix pythoncore.vcproj, Modules/_time.[ch] have been removed http://hg.python.org/cpython/rev/760cf150bb99 |
|||
| msg155639 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年03月13日 18:12 | |
New changeset 9d69a2418d80 by Victor Stinner in branch 'default': Issue #14180: Fix an invalid rounding when compiler optimization are enabled http://hg.python.org/cpython/rev/9d69a2418d80 |
|||
| msg155689 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年03月13日 23:20 | |
New changeset 5d6a5c5a4ebe by Victor Stinner in branch 'default': Issue #14180: datetime.date.fromtimestamp(), datetime.datetime.fromtimestamp() http://hg.python.org/cpython/rev/5d6a5c5a4ebe New changeset 706689b2d678 by Victor Stinner in branch 'default': Issue #14180: TestDateTime.test_microsecond_rounding() handles localtime() and http://hg.python.org/cpython/rev/706689b2d678 New changeset a0d101220f96 by Victor Stinner in branch 'default': Issue #14180: Fix the select module to handle correctly the Windows timeval http://hg.python.org/cpython/rev/a0d101220f96 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:27 | admin | set | github: 58388 |
| 2014年06月22日 07:57:17 | loewis | link | issue9012 superseder |
| 2012年03月13日 23:20:38 | python-dev | set | messages: + msg155689 |
| 2012年03月13日 18:12:26 | python-dev | set | messages: + msg155639 |
| 2012年03月13日 16:42:24 | python-dev | set | messages: + msg155631 |
| 2012年03月13日 15:25:45 | python-dev | set | messages: + msg155625 |
| 2012年03月13日 14:31:00 | python-dev | set | messages: + msg155616 |
| 2012年03月13日 12:50:39 | python-dev | set | messages: + msg155601 |
| 2012年03月13日 12:38:43 | python-dev | set | status: open -> closed nosy: + python-dev messages: + msg155600 resolution: fixed stage: resolved |
| 2012年03月05日 22:41:39 | vstinner | set | messages: + msg154984 |
| 2012年03月03日 00:10:21 | vstinner | create | |