At Wednesday 8/11/2006 07:18, Farraige wrote:

        for row_t1 in t1:
            for  row_t2 in t2:
                if [row_t1[i] for i in keyColumns] == [row_t2[j] for j
in keyColumns]:
                    # the keys are the same
                    for colName in columnsToBeUpdated:
                        row_t1[colName] = row_t2[colName]

                    # go outside the inner loop - we found a row with
                    # the same key in the table
                    break

In my algorithm I have 2 for loops and I have no idea how to optimise
it (maybe with map? )
I call this method for very large data and the performance is a
critical issue for me :(

def getkey(row):
  return tuple([row[i] for i in keyColumns])

Sort both tables using .sort(key=getkey); then traverse both in paralell like in classic merge; in 1 pass you get the job done (not counting the two initial sorts)


--
Gabriel Genellina
Softlab SRL
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to