I have written a program that reads data and updates the records
for some people. They are represented by objects, and I need to
read the data from a file, look the person up and then update
his record.
I have implemented this by creating a list with all the people's
names and another list
sert je...@hotmail.com wrote:
I have written a program that reads data and updates the records
for some people. They are represented by objects, and I need to
read the data from a file, look the person up and then update
his record.
I have implemented this by creating a list with all the
sert:
I have implemented this by creating a list with all the people's
names and another list with their objects (their data).
It works but after profiling the code it turns out that half the
time spent in the program is spent in the list.index() function
looking up names. Isn't there a less
bearophileh...@lycos.com wrote in
news:37632421-5475-4859-be83-07ae2eca1...@r4g2000yqa.googlegro
ups.com:
Try using a dict instead, where keys are the names and
objects the values (it turns a linear search in a quick
hash look up). . Then tell us the performance changes.
It halved the
2009/2/26 sert je...@hotmail.com:
bearophileh...@lycos.com wrote in
news:37632421-5475-4859-be83-07ae2eca1...@r4g2000yqa.googlegro
ups.com:
Try using a dict instead, where keys are the names and
objects the values (it turns a linear search in a quick
hash look up). . Then tell us the
relational database will be optimised to do these operations and so is
likely to be faster still. I think there are a couple that Python
works well with, but I've never looked into that -- others will no
doubt be along with recommendations now I've raised the subject.
batteries-included support