Fastest way to loop through each digit in a number?
rst at _nospam_.drlug.org._nospam_
Mon Sep 6 05:55:37 CEST 2004
Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:
>You could try timing something like
> while n:
> n,d = divmod(n, 10)
>That processes the digits in reverse order, of course.
It's faster! But Roy Smiths modulus (%) method is even faster. The
order does matter, but even when appending d to a list inside the loop
and reversing it when done, your methods are faster than my initial
More information about the Python-list