468,514 Members | 1,626 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,514 developers. It's quick & easy.

disk based dictionaries


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 Ma*******@wipro.com immediately
and destroy all copies of this message and any attachments.
Jul 18 '05 #1
3 2195
You may also want to take a look at ZODB (Zope database).
It handles the pickling, storage and retrieval of all
Python objects (including dictionaries) very well. And yes
you can use ZODB without using Zope proper.

http://www.zope.org/Products/StandaloneZODB

http://zope.org/Members/adytumsoluti...LoveZODB_PartI

http://www.h7.dion.ne.jp/~harm/ZODB-Tutorial.py
Larry Bates
Shivram U 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 Ma*******@wipro.com immediately
and destroy all copies of this message and any attachments.

Jul 18 '05 #2
You may also want to take a look at ZODB (Zope database).
It handles the pickling, storage and retrieval of all
Python objects (including dictionaries) very well. And yes
you can use ZODB without using Zope proper.

http://www.zope.org/Products/StandaloneZODB

http://zope.org/Members/adytumsoluti...LoveZODB_PartI

http://www.h7.dion.ne.jp/~harm/ZODB-Tutorial.py
Larry Bates
Shivram U 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 Ma*******@wipro.com immediately
and destroy all copies of this message and any attachments.

Jul 18 '05 #3
I'd like to second this suggestion. While there are a few things you
need to be aware of when writing your code (mostly taken care of in
the latest release) it's a mostly trivial code change. (For me it was
replacing a few dictionaries with PersistentMap objects and changing
the base class of a few objects to Persistant from object.

FWIW, I'm using ZODB to help track EDI transactions for a help desk
application. Right now my database hovers in the 100MB range with
several ten of thousands of objects. I also use it for single object
temp storage, so I feel it works well from both the small and mid-size
scale. (It probably works fine for large projects as well, I just
don't have one right now...)

Chris
On Thu, 02 Dec 2004 18:53:44 -0600, Larry Bates <lb****@syscononline.com> wrote:
You may also want to take a look at ZODB (Zope database).
It handles the pickling, storage and retrieval of all
Python objects (including dictionaries) very well. And yes
you can use ZODB without using Zope proper.

http://www.zope.org/Products/StandaloneZODB

http://zope.org/Members/adytumsoluti...LoveZODB_PartI

http://www.h7.dion.ne.jp/~harm/ZODB-Tutorial.py
Larry Bates


Shivram U 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 Ma*******@wipro.com immediately
and destroy all copies of this message and any attachments.

--
http://mail.python.org/mailman/listinfo/python-list

--
"It is our responsibilities, not ourselves, that we should take
seriously." -- Peter Ustinov
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Chris | last post: by
8 posts views Thread by robin | last post: by
8 posts views Thread by Foodbank | last post: by
57 posts views Thread by Chris Foote | last post: by
1 post views Thread by dopey483 | last post: by
1 post views Thread by qouify | last post: by
reply views Thread by M.-A. Lemburg | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.