storing large amounts of data in a list/dictionary

Discussion in 'Python' started by flamesrock, Mar 11, 2005.

  1. flamesrock

    flamesrock Guest

    Hi,

    Basically, what I'm trying to do is store large amounts of data in a
    list or dictionary and then convert that to a custom formatted xml
    file.

    My list looks roughly like this:
    (d[],r[c[d[p[],p[R,C,I]]]])

    My question is, would it be faster to use a dictionary if the elements
    of the lists have to be put in alphebetical order, or just use lists as
    above(since hashes are faster supposedly)?

    {d;d[],r;name[{d;d[{p;p[]}],c;name[{d;d[{p;p[]}]}]}]}

    Please consider the amount of code necessary to create/decode this

    (and sorry if this doesn't make any sense..)

    -thanks
     
    flamesrock, Mar 11, 2005
    #1
    1. Advertising

  2. flamesrock a écrit :
    > Hi,
    >
    > Basically, what I'm trying to do is store large amounts of data in a
    > list or dictionary and then convert that to a custom formatted xml
    > file.
    >
    > My list looks roughly like this:
    > (d[],r[c[d[p[],p[R,C,I]]]])
    >
    > My question is, would it be faster to use a dictionary if the elements
    > of the lists have to be put in alphebetical order,


    >>> d = {"e" : 32, "f": 44, "a" : 1, "z" : 99}
    >>> for k in d: print k

    ....
    a
    z
    e
    f

    Well... Just *don't* rely on *any* order with dicts.

    If you need fast keyed access to a very large dataset, you may want to
    have a look at btrees (one possible implementation here :
    http://zopewiki.org/BTree).

    Now since it's XML related, this may also (or not) be useful:
    http://effbot.org/zone/celementtree.htm
    http://effbot.org/zone/element-index.htm

    HTH
    Bruno
     
    Bruno Desthuilliers, Mar 11, 2005
    #2
    1. Advertising

  3. flamesrock

    flamesrock Guest

    Thanks for the reply ;)

    I was hoping not to complicate things with zope, tho Btrees look
    interesting.

    Oh - and about the xml, I'm using something very similar to elementree
    which I found in the python cookbook:
    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/157358

    Bruno Desthuilliers wrote:
    > flamesrock a écrit :
    > > Hi,
    > >
    > > Basically, what I'm trying to do is store large amounts of data in

    a
    > > list or dictionary and then convert that to a custom formatted xml
    > > file.
    > >
    > > My list looks roughly like this:
    > > (d[],r[c[d[p[],p[R,C,I]]]])
    > >
    > > My question is, would it be faster to use a dictionary if the

    elements
    > > of the lists have to be put in alphebetical order,

    >
    > >>> d = {"e" : 32, "f": 44, "a" : 1, "z" : 99}
    > >>> for k in d: print k

    > ...
    > a
    > z
    > e
    > f
    >
    > Well... Just *don't* rely on *any* order with dicts.
    >
    > If you need fast keyed access to a very large dataset, you may want

    to
    > have a look at btrees (one possible implementation here :
    > http://zopewiki.org/BTree).
    >
    > Now since it's XML related, this may also (or not) be useful:
    > http://effbot.org/zone/celementtree.htm
    > http://effbot.org/zone/element-index.htm
    >
    > HTH
    > Bruno
     
    flamesrock, Mar 12, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brent
    Replies:
    3
    Views:
    501
    Raymond Lewallen
    Apr 7, 2004
  2. Andersen
    Replies:
    2
    Views:
    399
  3. Bint
    Replies:
    1
    Views:
    1,902
    Benjamin Niemann
    Mar 19, 2006
  4. David
    Replies:
    0
    Views:
    334
    David
    Jun 21, 2006
  5. Replies:
    2
    Views:
    240
    Jyotirmoy Bhattacharya
    Jul 5, 2007
Loading...

Share This Page