[Tutor] populating an array or using a dictionary

Aditya Lal aditya.n.lal at gmail.com
Sun Oct 21 10:45:42 CEST 2007


If the ease of use is the only answer then the size of the file should not
matter ideally. btw, how large is the file ? is it in MBs or GBs ? For
performance reasons, typically you should not have any problems using either
dictionary, array or list for file size of few KBs.

Like Kent said, if you can sent some code it will throw light on how you
plan to use the data because the right data structure depends upon the
access pattern.

On 10/19/07, Eric Brunson <brunson at brunson.com> wrote:
>
> Bryan Fodness wrote:
> > The data file is larger than shown, and I was wondering if it would be
> > better to populate an array or create a dictionary.  Which would be
> > easier?
> >
>
> A dictionary is an array with an index, if you need an index into your
> data, use a dictionary, if not use an array.
>
>
> >
> > On 10/19/07, *Kent Johnson* <kent37 at tds.net <mailto:kent37 at tds.net>>
> > wrote:
> >
> >     Bryan Fodness wrote:
> >     > I have a data file that I would like to extract data from:
> >     >
> >     > FS   1   2   3   4   5
> >     > 1.5   1.000   1.000   1.000   1.000   1.000
> >     > 2.0   0.985   0.994   0.997   0.996   0.996
> >     > 2.5   0.967   0.976   0.981   0.981   0.982
> >     > 3.0   0.949   0.958   0.965   0.966   0.967
> >     > 3.5   0.925   0.937   0.945   0.948   0.951
> >     > 4.0   0.901   0.916   0.925   0.930   0.934
> >     > 4.5   0.882   0.896   0.906   0.912   0.917
> >     > 5.0   0.863   0.876   0.887   0.893   0.899
> >     >
> >     >
> >     > The first row is a variable d, and the first column is FS.  Any
> >     > suggestions on the best way to do this.
> >
> >     This looks the same as the question you asked on Wednesday...do
> >     you have
> >     some code already?
> >
> >     It helps if you can show what you have already done and ask for help
> >     with changes.
> >
> >     Kent
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Aditya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071021/ab4857a7/attachment-0001.htm 


More information about the Tutor mailing list