Nicola Musatti <[EMAIL PROTECTED]> writes: > > a = [f(x) + g(y) for x,y in izip(m1, m2) if h(x,y).frob() == 7] > > > > Consider how many intermediate objects are being allocated in figuring > > out that listcomp. Do you REALLY want to manage all the deallocation > > with something like RAII? > > What makes you think that a translation of a similar expression would > involve explicit dynamic allocation at all? Barring bugs, here's an > equivalent example: ...
There you replace one line of code with 40+ lines to get around the absence of GC. Sounds bug-prone among other things. > 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. -- http://mail.python.org/mailman/listinfo/python-list