Paul Rubin wrote: > Nicola Musatti <[EMAIL PROTECTED]> writes: >>> a = [f(x) + g(y) for x,y in izip(m1, m2) if h(x,y).frob() == 7] [...] > There you replace one line of code with 40+ lines to get around the > absence of GC. Sounds bug-prone among other things.
Come on, you didn't define f, g, izip, h or frob either. It's more like 5 to one. Furthermore your code is more compact due to the existence of list comprehensions, not because of GC. Had you written a loop the difference would be smaller. >> int f(int n) { return n * 2; } >> int g(int n) { return ( n * 2 ) + 1; } > > That is not a reasonable translation, since you've assumed the output > of f and g are integers that don't need to be dynamically allocated. > Maybe in the Python example, f and g and x and y are all bignums or > matrices or something like that. In my example I return a map by value just to show that it can be generalized to more complex data types. This is not C: in C++ you can go a long way without allocating dynamic memory explicitly. In my example std::map and std::vector do it for me. Cheers, Nicola Musatti -- Nicola.Musatti <at> gmail <dot> com Home: http://nicola.musatti.googlepages.com/home Blog: http://wthwdik.wordpress.com/ -- http://mail.python.org/mailman/listinfo/python-list