Bengt Richter <[EMAIL PROTECTED]> wrote:
   ...
> >Personally, I'd always use (depending on guesses regarding lengths of
> >lists) [x for x in l1 if x in l2] or the setified equivalent, of course.
> >
> Perhaps newbies should be advised that
> 
>     [x for x in l1 if x in set(l2)]
> 
> is not a (well) setified equivalent? I could see them being tempted.

You mean, newbies should be advised that Python does NOT hoist any
computations whatsoever from the body of a loop (including LCs and
genexps), so if you want anything hoisted you need to hoist it yourself?
Yes, it is a point worth making, since the lack of hoisting is a
frequent cause of performance loss.


Alex
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to