20 Aug
2009
20 Aug
'09
2:25 p.m.
On Thu, Aug 20, 2009 at 7:18 AM, Jeff McAninch<mcaninch@lanl.gov> wrote:
The bang-for-the-buck in the exception expression is in performance. ...
... doesn't a call to a python function (as opposed to a compiled C-function) substantially slow down a list comprehension?
Probably, but you don't have to use a comprehension. def g(seq): for e in seq: try: yield float(e) except: pass # whatever, even skipping the element If you don't need it in generator form, then just collect the results into a list and return that instead of yielding. (And obviously, that for loop doesn't even have to be in a separate (generator or) function at all.) -jJ