Thank you George Sakkis for your fast and accurate answer. In my life I am encountering lot of graph-based solutions to my problems. I'll try to implement your solution as soon as possible.
Fredrik Lundh>working on a Python to C/C++ translator without knowing what kind of optimizations a C/C++ compiler can do for you sounds like a great way to waste your time...< I am not the author of ShedSkin (Mark Dufour), I'm ignorant, he is much more expert than me about C++. So the possibile waste of time is just mine. Some experimental timings have shown me that different C++ compilers have different optimization capabilities, and such experiments show me that sometimes they (g++ of MinGW) aren't capable of doing some "obvious" optimizations (I haven't tested the assignments yet). Fredrik Lundh>the interesting thing is where the values came from, and what you're doing with the values later on. minimizing the number of assignment statements in the swap translation won't change a thing...)< I see. (It's just a detail, as I've said...) If you Fredrik have some free time and you are interested, you can probably help Mark Dufour improve that compiler. You can just email the author or post things in the Sourceforge site, etc. Bear hugs, bearophile -- http://mail.python.org/mailman/listinfo/python-list