Message105568
On Tue, May 11, 2010 at 10:19 PM, Alexander Belopolsky
<report@bugs.python.org> wrote:
..
> Similarly, while unlikely to improve performance, I would prefer not
> to use any bit-trick implementation of ilog2 (in a separate function,
> of course) instead of calling floating point log2. In my head, an
> assignment of floating point result to an integer variable always
> raises a red flag.
>
Searching for relevant past issues, I've come across a similar
sentiment from Mark:
"""
floor(log(n, 2)) is poor code. This is not supposed to be a dramatic
statement, just a statement of fact. Its correctness is dependent on
minute details of floating point. It is poor code in exactly the same way
that "while x < 1.0: x += 0.1" is poor code---behaviour in boundary cases
is almost entirely unpredictable.
""" - msg78066 - Mark Dickinson -
I also noticed that the reference implementation does not require this
calculation because the loop is implemented recursively. Did you find
recursive implementation to give worse performance? |
|
Date |
User |
Action |
Args |
2010-05-12 03:45:00 | belopolsky | set | recipients:
+ belopolsky, rhettinger, mark.dickinson, stutzbach |
2010-05-12 03:44:58 | belopolsky | link | issue8692 messages |
2010-05-12 03:44:57 | belopolsky | create | |
|