Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue13882] PEP 410: Use decimal.Decimal type for timestamps

 

 

First page Previous page 1 2 Next page Last page  View All Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Feb 2, 2012, 5:04 PM

Post #1 of 37 (70 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps

STINNER Victor <victor.stinner [at] haypocalc> added the comment:

As expected, size_t is too small on Windows 32 bits.

Patch version 8: _PyTime_t uses Py_LONG_LONG if available, instead of size_t, for numerator and denominator.

----------
title: Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object -> PEP 410: Use decimal.Decimal type for timestamps
Added file: http://bugs.python.org/file24402/time_decimal-8.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 2, 2012, 5:04 PM

Post #2 of 37 (60 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

Changes by STINNER Victor <victor.stinner [at] haypocalc>:


Removed file: http://bugs.python.org/file24372/time_decimal-5.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 2, 2012, 5:04 PM

Post #3 of 37 (60 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

Changes by STINNER Victor <victor.stinner [at] haypocalc>:


Removed file: http://bugs.python.org/file24378/time_decimal-6.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 2, 2012, 5:04 PM

Post #4 of 37 (60 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

Changes by STINNER Victor <victor.stinner [at] haypocalc>:


Removed file: http://bugs.python.org/file24396/time_decimal-7.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 2, 2012, 5:04 PM

Post #5 of 37 (60 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

Changes by STINNER Victor <victor.stinner [at] haypocalc>:


Removed file: http://bugs.python.org/file24402/time_decimal-8.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 2, 2012, 5:05 PM

Post #6 of 37 (60 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

STINNER Victor <victor.stinner [at] haypocalc> added the comment:

(Resend patch version 8 without the git diff format to support review on Rietveld.)

----------
Added file: http://bugs.python.org/file24403/time_decimal-8.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 2, 2012, 5:08 PM

Post #7 of 37 (60 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

Changes by STINNER Victor <victor.stinner [at] haypocalc>:


Removed file: http://bugs.python.org/file24403/time_decimal-8.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 2, 2012, 5:09 PM

Post #8 of 37 (60 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

STINNER Victor <victor.stinner [at] haypocalc> added the comment:

Oops, win32_pyclock() was disabled (for tests) in patch version 8. Fixed in version 9.

----------
Added file: http://bugs.python.org/file24404/time_decimal-9.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 3, 2012, 4:16 AM

Post #9 of 37 (49 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

STINNER Victor <victor.stinner [at] haypocalc> added the comment:

Patch version 10:
- deprecate os.stat_float_times()
- fix docstring of os.*stat() functions
- add a reference to the PEP
- add a comment to indicate that _PyTime_gettimeofday() ignores
integer overflow

----------
Added file: http://bugs.python.org/file24407/time_decimal-10.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
Attachments: time_decimal-10.patch (46.0 KB)


report at bugs

Feb 3, 2012, 4:24 PM

Post #10 of 37 (49 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

STINNER Victor <victor.stinner [at] haypocalc> added the comment:

Even if some people dislike the idea of adding datetime.datetime type, here is a patch implementing it (it requires time_decimal-XX.patch). The patch is at least a proof-of-concept that it is possible to change the internal structure without touching the public API.

Example:

$ ./python
>>> import datetime, os, time
>>> open("x", "wb").close(); print(datetime.datetime.now())
2012-02-04 01:17:27.593834
>>> print(os.stat("x", timestamp=datetime.datetime).st_ctime)
2012-02-04 00:17:27.592284+00:00
>>> print(time.time(timestamp=datetime.datetime))
2012-02-04 00:18:21.329012+00:00
>>> time.clock(timestamp=datetime.datetime)
ValueError: clock has an unspecified starting point
>>> print(time.clock_gettime(time.CLOCK_REALTIME, timestamp=datetime.datetime))
2012-02-04 00:21:37.815663+00:00
>>> print(time.clock_gettime(time.CLOCK_MONOTONIC, timestamp=datetime.datetime))
ValueError: clock has an unspecified starting point

As you can see: conversion to datetime.datetime fails with ValueError('clock has an unspecified starting point') for some functions, sometimes depending on the function argument (clock_gettime).

----------
Added file: http://bugs.python.org/file24414/timestamp_datetime.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 6, 2012, 2:50 PM

Post #11 of 37 (48 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

STINNER Victor <victor.stinner [at] haypocalc> added the comment:

Hum, time_decimal-10.patch contains a debug message:

+ print("la")

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 6, 2012, 2:59 PM

Post #12 of 37 (48 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

STINNER Victor <victor.stinner [at] haypocalc> added the comment:

- return posix_do_stat(self, args, "O&:stat", STAT, "U:stat", win32_stat_w);
+ return posix_do_stat(self, args, kw, "O&|O:stat", STAT, "U:stat", win32_stat_w);

The second format string should also be updated to "U|O:stat".

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 7, 2012, 3:27 PM

Post #13 of 37 (48 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

STINNER Victor <victor.stinner [at] haypocalc> added the comment:

Updated patch (version 11).

----------
Added file: http://bugs.python.org/file24445/time_decimal-11.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 7, 2012, 3:27 PM

Post #14 of 37 (48 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

Changes by STINNER Victor <victor.stinner [at] haypocalc>:


Removed file: http://bugs.python.org/file24404/time_decimal-9.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 7, 2012, 3:27 PM

Post #15 of 37 (48 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

Changes by STINNER Victor <victor.stinner [at] haypocalc>:


Removed file: http://bugs.python.org/file24407/time_decimal-10.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 7, 2012, 5:05 PM

Post #16 of 37 (48 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

STINNER Victor <victor.stinner [at] haypocalc> added the comment:

os.stat().st_birthtime should depend on the timestamp argument.

A timestamp optional argument should also be added to os.wait3() and os.wait4() for the utime and stime fields of the rusage tuple.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 7, 2012, 5:20 PM

Post #17 of 37 (48 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

STINNER Victor <victor.stinner [at] haypocalc> added the comment:

I created the issue #13964 to cleanup the API of os.*utime*() functions.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 7, 2012, 7:18 PM

Post #18 of 37 (48 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

STINNER Victor <victor.stinner [at] haypocalc> added the comment:

fill_time() should use denominator=1 if the OS doesn't support timestamp with a subsecond resolution. See also issue #13964.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 7, 2012, 7:57 PM

Post #19 of 37 (48 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

STINNER Victor <victor.stinner [at] haypocalc> added the comment:

Patch version 12:

* os.stat().st_birthtime uses also the timestamp argument
* Add an optional timestamp argument to os.wait3() and os.wait4(): change type of utime and stime attributes of the resource usage
* os.stat() changes the timestamp resolution depending if nanosecond resolution is available or not

I realized that resource.getrusage() should also be modified. I will maybe do that in another version of the patch, or maybe change resource usage in another patch.

----------
Added file: http://bugs.python.org/file24448/time_decimal-12.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 8, 2012, 3:52 PM

Post #20 of 37 (48 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

STINNER Victor <victor.stinner [at] haypocalc> added the comment:

Patch version 13:
- os.utime(path) sets the access and modification time using the currenet time with a subsecond resolution (e.g. microsecond resolution on Linux)
- os.*utime*() functions uses _PyTime_t type and functions
- add many functions to manipulate timeval, timespec and FILETIME types with _PyTime_t, add _PyTime_SetDenominator() function for that
- coding style: follow PEP 7 rules for braces

So more functions (including os.*utime*()) "accept" Decimal, but using an implicit conversion to float.

----------
Added file: http://bugs.python.org/file24461/time_decimal-13.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 8, 2012, 3:53 PM

Post #21 of 37 (48 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

Changes by STINNER Victor <victor.stinner [at] haypocalc>:


Removed file: http://bugs.python.org/file24445/time_decimal-11.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 8, 2012, 3:53 PM

Post #22 of 37 (48 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

Changes by STINNER Victor <victor.stinner [at] haypocalc>:


Removed file: http://bugs.python.org/file24448/time_decimal-12.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 9, 2012, 5:48 PM

Post #23 of 37 (48 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

STINNER Victor <victor.stinner [at] haypocalc> added the comment:

Patch version 14:

- rewrite the conversion from float to _PyTime_t: use base 2 with high precision and then simplify the fraction. The conversion from decimal.Decimal uses base 10 and do also simplify the fraction.
- write tests on functions converting _PyTime_t using _testcapi
- add timestamp argument to signal.getitimer(), signal.setitimer(), resource.getrusage()
- signal.sigtimedwait() uses _PyTime_t and now expects a number and no more a tuple (function added to Python 3.3, so no backward compatibility issue). See also the issue #13964
- time.sleep() uses _PyTime_t. See also the issue #13981 (use nanosleep())
- datetime.datetime.now() and datetime.datetime.utcnow() uses _PyTime_t
- catch integer overflow on _PyTime_AsTimeval(), _PyTime_AsTimespec() and more

This patch gives you an overview of the whole PEP 410 implementation, but it should not be applied in one shot. It would be better to commit it step by step:

- add _PyTime_t API
- use _PyTime_t for the time module
- use _PyTime_t for the os module
- use _PyTime_t for the more modules
- etc.

We can start by adding the API and use it in the time module, and then rediscuss changes on other modules.

----------
Added file: http://bugs.python.org/file24473/time_decimal-14.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 9, 2012, 5:49 PM

Post #24 of 37 (48 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

Changes by STINNER Victor <victor.stinner [at] haypocalc>:


Removed file: http://bugs.python.org/file24461/time_decimal-13.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Feb 12, 2012, 3:11 AM

Post #25 of 37 (30 views)
Permalink
[issue13882] PEP 410: Use decimal.Decimal type for timestamps [In reply to]

STINNER Victor <victor.stinner [at] haypocalc> added the comment:

Patch version 15:
- round "correctly"
- datetime.date.fromtimestamp() and datetime.datetime.fromtimestamp() reuses _PyTime_t API to support decimal.Decimal without loss of precision
- add more tests

----------
Added file: http://bugs.python.org/file24495/time_decimal-15.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue13882>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

First page Previous page 1 2 Next page Last page  View All Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.