Optimisation problem

Erik Max Francis max at alcyone.com
Tue Nov 12 16:15:03 EST 2002


gabor wrote:

> you're saying that for example
> 
> x,y = 2,4
> 
> creates a tuple?
> 
> i thought thatr x,y=2,4 is the same as x=2;y=4

It does the same thing, but it creates a tuple (right hand side) and
then unpacks it (left hand side) to do the multiple assignment.

Technically speaking, the separate assignments will be faster (since
they do not have the overhead of creating and the unpacking a tuple). 
However, as I've maintained before, if you're _really_ in the situation
where this tiny change will make the difference between unacceptable run
times and unacceptable runtimes, Python is probably not the proper
choice of language for your project anyway.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ If a thing is worth doing, then it is worth doing badly.
\__/ G.K. Chesterton
    ZOE / http://www.alcyone.com/pyos/zoe/
 A simple Python OpenGL rendering engine.



More information about the Python-list mailing list