What would be faster ? Query mysql to see if the piece of information i need is there, OR load a python dictionary with all the information then just check if the id is there
If python is faster, then whats the best what to check if the id exists?
Im using python 2.4.3
Im searching for data which is tagged to a square on a board, im searching for x&y. Theres only one entry per square, the information wont change and it needs be recalled several times a second.
Thankyou !
Finished
I worked out it was python. I ran the code bellow, and mysql did it in 0.0003 of a second, but python did it in 0.000006 of a second and mysql had far far less to search and the test was run how the code would be running in real life. Which one had less overhead in terns of CPU and RAM i will never know but if speed is anything to go by python did much better.
And thankyou for your answers !
def speedtest():
global search
global data
qb = time.time()
search.execute("SELECT * FROM `nogo` where `1`='11' AND `2`='13&3'")
qa = search.fetchall()
print qa[0]
qc = time.time()
print "mysql"
print qb
print qc
print qc - qb
data = {}
for qa in range(15):
data[qa] = {}
for qb in range(300):
data[qa][str(qb)] = 'nogo'
qw = 5
qe = '50'
qb = time.time()
print data[qw][qe]
qc = time.time()
print "dictionary"
print qb
print qc
print qc - qb