[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-02-02 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Patch version 7: - Drop datetime.datetime and datetime.timedelta types - Conversion to decimal now uses a context with 1 digit to compute exponent=1/denominator to avoid issue on t.quantize(exponent) - Rename the format argument

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-31 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Patch version 6: - timestamp format is now a type instead of a string, e.g. time.time(int) - add int and datetime.timedelta formats, remove timespec format - complete the documentation - fix integer overflows, convert correctly

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-31 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Hum, it looks like _PyTime_AsDecimal() is wrong is ts-divisor is not a power of 10. The exponent must be computed with Context(1), not Context(26). Something simpler can maybe be used, I don't know even the decimal API. --

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-30 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Version 5: - add datetime and timespec formats: datetime.datetime object and (sec: int, nsec: int) - add timestamp optional format to os.stat(), os.lstat(), os.fstat(), os.fstatat() - support passing the timestamp format as a

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-30 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@haypocalc.com: Removed file: http://bugs.python.org/file24367/time_decimal-4.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13882 ___

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-30 Thread Alexander Belopolsky
Alexander Belopolsky alexander.belopol...@gmail.com added the comment: On Sun, Jan 29, 2012 at 6:42 PM, STINNER Victor rep...@bugs.python.org wrote: .. What do you call a constant argument? float and decimal? You would prefer a constant like time.FLOAT_FORMAT? Or maybe a boolean

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-30 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: One possibility (still awkward IMO) would be to use the return type as the format specifier. Yeah, I already thaught to this idea. The API would be: - time.time(format=float) - time.time(format=decimal.Decimal) -

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-30 Thread Alexander Belopolsky
Alexander Belopolsky alexander.belopol...@gmail.com added the comment: On Mon, Jan 30, 2012 at 6:15 PM, STINNER Victor rep...@bugs.python.org wrote: Another possibility is what I proposed before in the issue #11457: take a callback argument. http://bugs.python.org/issue11457#msg143738 I

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-29 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Constant arguments What do you call a constant argument? float and decimal? You would prefer a constant like time.FLOAT_FORMAT? Or maybe a boolean (decimal=True)? I chose a string because my first idea was to add a registry to

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-29 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Patch version 4, minor update: - remove the resolution field of _PyTime_t and remove int_log10(): use 1/divisior as the resolution to support divisor different than a power of 10 (e.g. the cpu frequency on Windows) - inline and

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-29 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@haypocalc.com: -- assignee: - Arfrever Added file: http://bugs.python.org/file24367/time_decimal-4.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13882

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-29 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@haypocalc.com: Removed file: http://bugs.python.org/file24330/time_decimal-2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13882 ___

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-29 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@haypocalc.com: Removed file: http://bugs.python.org/file24331/time_decimal-3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13882 ___

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-29 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Another possible format would be tuple Or, I forgot an obvious format: datetime! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13882

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-29 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@haypocalc.com: -- assignee: Arfrever - ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13882 ___ ___

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-29 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@haypocalc.com: -- nosy: +skrah ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13882 ___ ___

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-27 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13882 ___

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-27 Thread Alexander Belopolsky
Alexander Belopolsky alexander.belopol...@gmail.com added the comment: Can we pick an API for this functionality that does not follow the worst of design anti-patterns? Constant arguments, varying return type, hidden import, and the list can go on. What is wrong with simply creating a new

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-27 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Well, creating a separate module is an anti-pattern in itself. calendar vs. time vs. datetime, anyone? I would instead propose separate functions: decimal_time, decimal_clock... or, if you prefer, time_decimal and so on. -- nosy:

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-27 Thread Alexander Belopolsky
Alexander Belopolsky alexander.belopol...@gmail.com added the comment: On Fri, Jan 27, 2012 at 5:17 PM, Antoine Pitrou rep...@bugs.python.org wrote: Well, creating a separate module is an anti-pattern in itself. calendar vs. time vs. datetime, anyone? Are you serious? Since the invention of

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-27 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Are you serious? Since the invention of structural programming, creating a separate module for distinct functionality has been one of the most powerful design techniques. Yes, I'm serious, and I don't see what structural programming or design

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-27 Thread Alexander Belopolsky
Changes by Alexander Belopolsky alexander.belopol...@gmail.com: -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13882 ___

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-27 Thread Eric V. Smith
Changes by Eric V. Smith e...@trueblade.com: -- nosy: +eric.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13882 ___ ___ Python-bugs-list

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-26 Thread STINNER Victor
New submission from STINNER Victor victor.stin...@haypocalc.com: Attached patch adds an optional format argument to time.time(), time.clock(), time.wallclock(), time.clock_gettime() and time.clock_getres() to get the timestamp as a different format. By default, the float type is still used,

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-26 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Some examples of the API: $ ./python Python 3.3.0a0 (default:52f68c95e025+, Jan 26 2012, 21:54:31) import time time.time() 1327611705.948446 time.time('decimal') Decimal('1327611708.988419') t1=time.time('decimal');

[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-26 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Windows code (win32_clock) was wrong in time_decimal-2.patch: it is fixed in patch version 3. Some tests on Windows made me realize that time.time() has a resolution of 1 millisecond (10^-3) and not of a microsecond (10^-6) on