Sopoforic Agents in Childhood

Just another WordPress.com weblog

Archive for December, 2008

Things I Learned About Python

Posted by Tracy Poff on December 24, 2008

Sometimes dictionaries are better than lists.

I had a huge list of numbers, and I was generating new numbers which I needed to check for membership in the list. So, I was doing lots of item in list. However this proved to be very slow. So slow that the program would have run for several days before completing.

So, I stuck all of the list items in a dictionary and did dictionary.has_key(item). The program ran in about a second.

Lesson: Use the right tool for the job.

Posted in Uncategorized | Tagged: , | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.