Re: searching in list

2011-05-30 Thread Ian Kelly
On Mon, May 30, 2011 at 7:41 AM, Chris Angelico wrote: > If you're always going to look them up by the argument, the best way > would be to use a dictionary: > cache={arg1: res1, arg2: res2, ...} > > Then you can search with a simple: cache[arg135] > > You can add things with: cache[arg135]=res135

Re: searching in list

2011-05-30 Thread Chris Angelico
On Mon, May 30, 2011 at 11:50 PM, vino19 wrote: > Thanks. > > It seems that dictionary is a sorted list of tuples, so the procedure of > searching an element is quite quick. Not sorted - it's hashed, so it's even faster. Yep, sounds like a dictionary is everything you want! Chris Angelico -- h

Re: searching in list

2011-05-30 Thread vino19
Thanks. It seems that dictionary is a sorted list of tuples, so the procedure of searching an element is quite quick. -- http://mail.python.org/mailman/listinfo/python-list

Re: searching in list

2011-05-30 Thread Chris Angelico
On Mon, May 30, 2011 at 10:58 PM, vino19 wrote: > I want to make a function that is called only once per one argument. I mean I > want to store data of function calling to prevent calling it again if there > is no need. > How to make it? For example I can make a global list that just consist of

Re: searching in list

2011-05-30 Thread Dave Angel
On 01/-10/-28163 02:59 PM, vino19 wrote: I want to make a function that is called only once per one argument. I mean I want to store data of function calling to prevent calling it again if there is no need. How to make it? For example I can make a global list that just consist of tuples [(arg1,

searching in list

2011-05-30 Thread vino19
I want to make a function that is called only once per one argument. I mean I want to store data of function calling to prevent calling it again if there is no need. How to make it? For example I can make a global list that just consist of tuples [(arg1, res1), (arg2, res2), ...]. Ok, how to se