[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pygame] Does anyone have a python implementation of A*?
Pete Shinners <shredwheat@attbi.com>:
>
> Bob Ippolito wrote:
> > I think the point of difference is that the for loops in list
> > comprehensions are more likely C for loops, like with the builtins (map,
> > reduce, zip, etc)
>
> sadly not really. list comprehensions are the same speed as for loops.
>
> newlist = []
> for x in oldlist:
> newlist.append(abs(x))
>
> results in nearly identical speed with the list comprehension:
>
> newlist = [abs(x) for x in oldlist]
>
> of course, for simple problems like this, the map/filter/reduce family
> can run them a bit quicker:
>
> newlist = map(abs, oldlist)
>
My point exactly. As far as I know, list comprehensions are translated
into the same bytecode as the equivalent for loop. (At least I think
I've heard that.)
--
Magnus Lie Hetland The Anygui Project
http://hetland.org http://anygui.org
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org