[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [pygame] Does anyone have a python implementation of A*?
I did a de-compile to check this a while back, and
it's true (listcomps == for loops). The 100x speedup should not have
happened -
are you sure you didn't change the nature of the algol
by mistake?? For loops are usually a little faster than list-comps
because you don't need to allocate the side-effects list
if you don't want it. And the C-coded map, etc., is usually the fastest,
even
with the allocations.
On a related note, has anyone tried psycho
with a pygame? (Not sure if it's prime-time yet, but I thought it
handled numerics well at least.)
m
-----Original Message-----
From: owner-pygame-users@seul.org [mailto:owner-pygame-users@seul.org]On
Behalf Of Magnus Lie Hetland
Sent: Saturday, February 16, 2002 3:35 PM
To: pygame-users@seul.org
Subject: 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
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org