Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6667941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:59:11+00:00 2026-05-26T02:59:11+00:00

I was thinking that native DBM of Python should be quite faster than NOSQL

  • 0

I was thinking that native DBM of Python should be quite faster than NOSQL databases such as Tokyo Cabinet, MongoDB, etc (as Python DBM has lesser features and options; i.e. a simpler system). I tested with a very simple write/read example as

#!/usr/bin/python
import time
t = time.time()
import anydbm
count = 0
while (count < 1000):
 db = anydbm.open("dbm2", "c")
 db["1"] = "something"
 db.close()
 db = anydbm.open("dbm", "r")
 print "dict['Name']: ", db['1'];
 print "%.3f" % (time.time()-t)
 db.close()
 count = count + 1

Read/Write: 1.3s
Read: 0.3s
Write: 1.0s

These values for MongoDb is at least 5 times faster. Is it really the Python DBM performance?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:59:12+00:00Added an answer on May 26, 2026 at 2:59 am

    Python doesn’t have a built-in DBM implementation. It bases its DBM functions on a wide range of DBM-style third party libraries, like AnyDBM, Berkeley DBM and GNU DBM.

    Python’s dictionary implementation is really fast for key-value storage, but not persistent. If you need high-performance runtime key-value lookups, you may find a dictionary better – you can manage persistence with something like cpickle or shelve. If startup times are important to you (and if you’re modifying the data, termination) – more important than runtime access speed – then something like DBM would be better.

    In your evaluation, as part of the main loop you have included both dbm open calls and also array lookup. It’s a pretty unrealistic use case to open a DBM to store one value and the close and re-open before looking it up, and you’re seeing the typical slow performance that one would when managing a persistent data store in such a manner (it’s quite inefficient).

    Depending on your requirements, if you need fast lookups and don’t care too much about startup times, DBM might be a solution – but to benchmark it, only include writes and reads in the loop! Something like the below might be suitable:

    import anydbm
    from random import random
    import time
    
    # open DBM outside of the timed loops
    db = anydbm.open("dbm2", "c")
    
    max_records = 100000
    
    # only time read and write operations
    t = time.time()
    
    # create some records
    for i in range(max_records):
      db[str(i)] = 'x'
    
    # do a some random reads
    for i in range(max_records):
      x = db[str(int(random() * max_records))]
    
    time_taken = time.time() - t
    print "Took %0.3f seconds, %0.5f microseconds / record" % (time_taken, (time_taken * 1000000) / max_records)
    
    db.close()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been always thinking that DOMNodeInsertedIntoDocument/DOMNodeRemovedFromDocument events should not bubble, and for me that
I was thinking that the SQLDataReader should not work if there is no connection
Am I correct in thinking that that Python doesn't have a direct equivalent for
I'm thinking in making an app that send e-mails without showing the native iOS
Thinking that the answer to this is pretty obvious but here it goes: When
I'm thinking that the reason I can't do this is because it might be
I was thinking that i wanted to gain some experience in the new asp.net
I am thinking that I create a deactivation code put that in the unsubscribe
Am I right in thinking that until I am able to afford dedicated servers
I was thinking that at the top of my partial I would have something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.