[Python-Dev] accumulator display syntax

Skip Montanaro skip at pobox.com
Fri Oct 24 08:37:38 EDT 2003


 Tim> squares = (f(x)**2 for x in inputs) # assuming reiterability here
 Tim> for f in math.sin, math.cos, math.tan:
 Tim> plot(squares)
How much more expensive would this be than
 for f in math.sin, math.cos, math.tan:
 squares = (f(x)**2 for x in inputs)
 plot(squares)
which would work without reiterability, right? The underlying generator
function could still be created at compile-time and it (or its code object?)
stored in the current function's constants. 'f' is simply an argument to it
when the iterator is instantiated.
Skip


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /