Efficient searching through objects
rdmurray at bitdance.com
rdmurray at bitdance.com
Thu Feb 26 07:20:16 EST 2009
sert <jerry at 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 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 goofy and more efficient
> way of doing this?
It sounds like what you are looking for is the dictionary
data type.
--RDM
More information about the Python-list
mailing list