Chris Kaynor <ckay...@zindagigames.com> writes: > That code is substantially different that the code that Steven > D'Aprano posted: Steven's uses filter to call the lambdas, while your > calls the lambdas from another lambda.
I wouldn't have thought it made a difference, but apparently it does. Thanks. > Basically, yours has direct recursion in the Python code, while > Steven's does not. I would have said: both have deeply nested function calls but no recursion per se. I did another test with Python 2.7.5 under Idle: from itertools import ifilter def f(xs): return ifilter(lambda x:True, xs) def t(n): xs = range(10) for i in xrange(n): xs = f(xs) print list(xs) and it seemed to survive up to around 130k nested filters, with a slightly non-deterministic limit: 130900 worked some of the time and crashed some of the time. Interesting. -- https://mail.python.org/mailman/listinfo/python-list