Alexander Belopolsky <belopol...@users.sourceforge.net> added the comment:

On Tue, May 11, 2010 at 10:19 PM, Alexander Belopolsky
<rep...@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?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8692>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to