[Tutor] Speed it up...
trias
t.gkikopoulos at dundee.ac.uk
Thu May 27 11:37:20 CEST 2010
Hi,
I have wrote the following lines that work fine, but are quite slow, are
there any obvious things I can consider to speed things up?
Thanks
import MySQLdb
import scipy
import csv
dbtest=MySQLdb.connect(host="***",user="***",passwd="***")
cursor=dbtest.cursor()
cursor.execute("""SELECT tfs_name FROM tfs_sites GROUP by tfs_name""")
result=cursor.fetchall()
dbtest.close()
TFname=[]
for row in result:
TFname.append(row[0])
del result
T={}
i=0
for TF in TFname:
while i<1:
dbtest=MySQLdb.connect(host="***",user="***",passwd="***",db="***")
cursor=dbtest.cursor()
cursor.execute("""SELECT tfs_chr,tfs_pos,tfs_val FROM tfs_sites
WHERE tfs_name='%s'"""%(TF))
result=cursor.fetchall()
TFchr=[]
TFpos=[]
TFval=[]
i+=1
for row in result:
TFchr.append(row[0])
TFpos.append(row[1])
TFval.append(row[2])
TFc=[[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]]
counter=0
for TFsite in TFchr:
TFc[(int(TFsite)-1)].append((int(TFpos[counter]),int(TFval[counter])))
T[TF]=TFc
counter+=1
--
View this message in context: http://old.nabble.com/Speed-it-up...-tp28691677p28691677.html
Sent from the Python - tutor mailing list archive at Nabble.com.
More information about the Tutor
mailing list