At 01:00 PM 6/14/2006 -0700, Josiah Carlson wrote: > > That claim isn't necessarily supported by your benchmark, which includes > > the time to *define* the nested function 10 times, but calls it only 45 > > times! Try comparing fcn1(1000) and fcn2(1000) - I suspect the results > > will be somewhat closer, but probably still in favor of fcn1. > >Please re-read the code and test as I have specified. You seem to have >misunderstood something in there, as in the example I provide, _helper >is called 1,000,000 times (and is defined only once for each call of >fcn2) during each fcn1 or fcn2 call, and _helper is only defined once >inside of fcn2.
Oops. I misread "[fcn2(x) for i in xrange(10)]" as "[fcn2(x) for x in xrange(10)]". The latter is so much more common of a pattern that I guess I didn't even *look* at what the loop variable was. Weird. I guess the mind is a terrible thing. :) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com