Re: performance question: dictionary or list, float or string?

2008-12-04 Thread bkamrani
On Dec 4, 1:28 pm, alex23 <[EMAIL PROTECTED]> wrote: > On Dec 4, 8:12 pm, [EMAIL PROTECTED] wrote: > > > About the piece of code you posted, there is something I don't > > understand. > > >         for i, line in data: > > > where data is a file object. Is it legal to write that? > > I believe it r

Re: performance question: dictionary or list, float or string?

2008-12-04 Thread alex23
On Dec 4, 8:12 pm, [EMAIL PROTECTED] wrote: > About the piece of code you posted, there is something I don't > understand. > >         for i, line in data: > > where data is a file object. Is it legal to write that? > I believe it results in "too many values to unpack" or do I miss > something? >F

Re: performance question: dictionary or list, float or string?

2008-12-04 Thread bkamrani
About the piece of code you posted, there is something I don't understand. for i, line in data: where data is a file object. Is it legal to write that? I believe it results in "too many values to unpack" or do I miss something? /Ben On Dec 4, 10:26 am, [EMAIL PROTECTED] wrote: > Matt, r

Re: performance question: dictionary or list, float or string?

2008-12-04 Thread bkamrani
Matt, really thanks for your comments! Even thogh it was not a direct answer to my questions, I like your coding style very much and I think you have a good point. About the number of line in the file, because I get that info from another in advance. Therefore I thought it could be hard coded. BT

Re: performance question: dictionary or list, float or string?

2008-12-04 Thread bkamrani
Thanks for your questions. Here come some answer below. On Dec 2, 2:50 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Tue, 02 Dec 2008 03:41:29 -0800,bkamraniwrote: > > Hi Python gurus! > > I'm going to read in an Ascii file containing float numbers in rows and > > columns

Re: performance question: dictionary or list, float or string?

2008-12-02 Thread Matimus
On Dec 2, 3:51 am, [EMAIL PROTECTED] wrote: > I forgot to mention that I did a simple timeit test which doesn't > show > significant runtime difference 3.5 sec for dictionary case and 3.48 > for > list case. > > def read_as_dictionary(): >     fil = open('myDataFile', 'r') >     forces = {} >     f

Re: performance question: dictionary or list, float or string?

2008-12-02 Thread Steven D'Aprano
On Tue, 02 Dec 2008 03:41:29 -0800, bkamrani wrote: > Hi Python gurus! > I'm going to read in an Ascii file containing float numbers in rows and > columns (say 10 columns 50 rows) for further numerical process. > Which format is best to save them in, eg, dictionary, list, or numpy > array when

Re: performance question: dictionary or list, float or string?

2008-12-02 Thread bkamrani
I forgot to mention that I did a simple timeit test which doesn't show significant runtime difference 3.5 sec for dictionary case and 3.48 for list case. def read_as_dictionary(): fil = open('myDataFile', 'r') forces = {} for region in range(25): forces[region] = {} for s

performance question: dictionary or list, float or string?

2008-12-02 Thread bkamrani
Hi Python gurus! I'm going to read in an Ascii file containing float numbers in rows and columns (say 10 columns 50 rows) for further numerical process. Which format is best to save them in, eg, dictionary, list, or numpy array when it comes to performance? Will it be beneficial to convert all