Python BUG?

Fredrik Lundh fredrik at pythonware.com
Wed Jan 12 04:26:27 EST 2000


Oleg Orlov <orlov at diasoft.ru> wrote:
> This script:
> 
> d = [1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
>     10L, 9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L]
> print reduce(lambda x, y: x*x + y*y, d)
> 
> hangs up my python interpreter (on NT4).
> 
> Is it a bug or my mistake?

neither.  it's just that your computer is not quite
as fast as you think it is...

to see what I mean, replace the lambda with a
function that prints the intermediate result, or
some variation of it.  e.g.

def f(x, y):
    v = x*x + y*y
    print len(str(v))
    return v

print reduce(f, d)

</F>





More information about the Python-list mailing list