[Python-Dev] Floor division (original) (raw)
Guido van Rossum guido at python.org
Thu Jan 25 22:22:54 CET 2007
- Previous message: [Python-Dev] Floor division
- Next message: [Python-Dev] Floor division
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The only thing I would miss about this is that I am used to write certain timing loops that like to sync on whole seconds, by taking time.time() % 1.0 which nicely gives me the milliseconds in the current second. E.g.
while True: do_something_expensive_once_a_second_on_the_second() now = time.time() time.sleep(1.0 - (now % 1.0))
I guess I could use (now - int(now)) in a pinch, assuming int() continues to truncate.
--Guido
On 1/25/07, Armin Rigo <arigo at tunes.org> wrote:
Hi Tim,
On Tue, Jan 23, 2007 at 05:14:29PM -0500, Tim Peters wrote: > For some reason
decimal
implemented mod as the proposed > standard's "remainder" operation. That's the immediate source of your > surprise. IMOdecimal
should not have implemented mod at all, > as Python's number-theoretic mod is not part of the proposed standard, > is a poor basis for a floating-point mod regardess, and it was a > mistake to implement decimal % decimal in a way so visibly different > from float % float and integer % integer: it confuses the meaning of > "%". That's your complaint, right? Thanks for the clarification. Yes, it makes sense that mod, divmod and floordiv on float and decimal would eventually follow the same path as for complex (where they make even less sense and already raise a DeprecationWarning).A bientot, Armin.
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] Floor division
- Next message: [Python-Dev] Floor division
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]