[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Does anyone have a python implementation of A*?



Hmm... I didn't make many other changes besides what was needed to
change to comprehensions. I'll mess around more to test what is actually
responsible.

Just to be sure we're all on the same page, I'm using python 2.1.2.

Magnus Lie Hetland wrote:

> 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

-- 

John Eikenberry
[jae@zhar.net - http://zhar.net]
______________________________________________________________
"They who can give up essential liberty to purchase a little temporary
 safety, deserve neither liberty nor safety."
                                          --B. Franklin
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org