Re: disk based dictionaries

From: Shivram U (shivaram.upadhyayula_at_wipro.com)
Date: 12/03/04


To: Steve <lonetwin@gmail.com>, Larry Bates <lbates@syscononline.com>
Date: 03 Dec 2004 22:39:51 +0600


Hi Steve, Larry,
   Thanks for the Help! I am using the pickle module now as i just need
to store and retrieve dictionaries.

Best Regards,
Shivram U

On Thu, 2004-12-02 at 23:59, Steve wrote:
> Hi Shivam,
>
> If storing and retrieving is all that you are interested in, you
> should consider 'pickling' your dicts, using python's pickle module.
> It's part of the standard library.
> Learn more about it here:
> http://docs.python.org/lib/module-pickle.html
>
> Here's an example usage:
>
> [steve@sfernandez20 ~]$ python
> Python 2.3.4 (#2, Aug 19 2004, 15:49:40)
> [GCC 3.4.1 (Mandrakelinux (Alpha 3.4.1-3mdk)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import pickle
> >>> d = {'foo':'bar', 1:'ham', 'eggs':10}
> >>> fl = open('mydict', 'wb')
> >>> pickle.dump(d, fl)
> >>> del(d)
> >>> dir()
> ['__builtins__', '__doc__', '__file__', '__name__', 'fl', 'pickle']
> >>> fl.close()
> >>> fl = open('mydict')
> >>> d = pickle.load(fl)
> >>> d
> {1: 'ham', 'eggs': 10, 'foo': 'bar'}
> >>>
>
> HTH
> Regards
> steve
>
>
> On 02 Dec 2004 20:33:22 +0600, Shivram U <shivaram.upadhyayula@wipro.com> wrote:
> >
> > Hi,
> >
> > I want to store dictionaries on disk. I had a look at a few modules
> > like bsddb, shelve etc. However would it be possible for me to do the
> > following
> >
> > hash[1] = [1, 2, 3] where the key is an int and not a string
> >
> > bsddb requires that both the key,value are string.
> > shelve does support values being object but not the keys. Is there any
> > module which support keys which are not strings
> >
> > Also how do i use disk based hashes for multidimensional hashes such as
> > below
> >
> > #!/usr/bin/python
> >
> > dict={}
> > dict['key1'] = {}
> > dict[('key1')][('key2')] = 'value'
> >
> > key1=dict['key1']
> > print key1['key2']
> >
> > I have read of mxBeeDict but was unable to get it work properly. I am
> > not sure if it supports what i need as i was unable to get any
> > documentation about it. Is the module used widely ?
> >
> > Below is how i am using the module
> >
> > bdict = BeeDict('/tmp/beedict')
> >
> > bdict[1] = 1
> > print bdict.keys()
> >
> > bdict.commit()
> > bdict.close()
> >
> > bdict1 = BeeDict('/tmp/beedict')
> > print bdict1.keys()
> > print bdict1.values()
> >
> > Would it be that using disk based dictionaries once opened are as fast
> > as in memory dictionaries ?
> >
> > Thanks in advance,
> >
> > Best Regards,
> > Shivram U
> >
> > Confidentiality Notice
> >
> > The information contained in this electronic message and any attachments to this message are intended
> > for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
> > you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
> > and destroy all copies of this message and any attachments.
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >

Confidentiality Notice

The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.



Relevant Pages

  • Radius Client
    ... Regards, ... Mitali Vemuganti ... The information contained in this electronic message and any attachments to this message are intended ... you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately ...
    (freebsd-questions)
  • Sunsolve username and password
    ... Regards ... Ashish ... The information contained in this electronic message and any attachments to ... you are not the intended recipient, please notify the sender at Wipro or ...
    (SunManagers)
  • DBD Oracle download
    ... Regards, ... > Balkrishna Sapre. ... The information contained in this electronic message and any attachments to this message are intended ... you are not the intended recipient, please notify the sender at Wipro or Mailadmin@xxxxxxxxx immediately ...
    (perl.dbi.users)
  • Re: Can I change Outlook 2000 default attachment folder?
    ... Amon ... >> Regards, ... This e-mail and any attachments thereto contain proprietary information some ... intended recipient is strictly prohibited. ...
    (microsoft.public.outlook)
  • Re: sunmanagers Digest, Vol 11, Issue 6
    ... check this e-mail and any attachments for viruses. ... > not an easy way of doing it, since my print server is ... >> Regards, ... > I did a tail on the messages file to get a stop action of the flying ...
    (SunManagers)