GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — DBM Module Vacuuming · Issue #134004 · python/cpython

DBM Module Vacuuming #134004

New issue
Copy link
New issue
Copy link
Closed
#134028
Closed
DBM Module Vacuuming#134004
#134028
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

@Andrea-Oliveri
Andrea-Oliveri
opened on May 14, 2025
Issue body actions

Feature or enhancement

Proposal:

Good afternoon,
The dbm module, and by extension shelve as well, don't provide any way to reclaim free space when lots of deletions from the database happen. This applies to all of the dbm submodules (dbm.dumb, dbm.sqlite, dbm.ndbm, dbm.gnu).

This can lead to hundreds of GB of wasted space when using them to store complex objects, such as when using them as a persistent cache.

Most of the underlying libraries, however, support ways to retrieve space on-demand:

  • VACUUM in sqlite3
  • gdbm_reorganize for gnu
  • None for ndbm
  • None for dumb (but this is simple to implement and I would be happy to contribute: in-place copies used parts of the binary file and updates the index. The advantage is this won’t use more disk space while vacuuming, but if program is interrupted during vacuum, DB will be corrupted (note: this is the case for many dbm.dumb operations already)

Additionally, I would like to update the documentation to highlight the disadvantages of dbm.dumb. For now they are only comments in the source code and are hidden from developers reading the doc:

  • Lack of support for any concurrency
  • Slowness linearly proportional to index size
  • (This will hopefully be fixed by the PR so it won't be included but otherwise also) never retrieves space of deleted items.

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/dbm-module-add-vacuuming/91507

Linked PRs

  • gh-134004: Dbm vacuuming #134028

Activity

  1. Andrea-Oliveri
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on May 14, 2025
  2. serhiy-storchaka commented on May 15, 2025

    @serhiy-storchaka
    serhiy-storchaka
    on May 15, 2025
    Member
    More actions

    Why not call it reorganize(), for compatibility with gdbm?

  3. Andrea-Oliveri commented on May 15, 2025

    @Andrea-Oliveri
    Andrea-Oliveri
    on May 15, 2025
    ContributorAuthor
    More actions

    Thank you @serhiy-storchaka, perfectly valid question whose logic I can't confute. I have updated the pull request changing the method names accordingly 😅

  4. picnixz
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on May 15, 2025
  5. picnixz
    added this to dbm and shelve issueson May 15, 2025
  6. Andrea-Oliveri commented on May 27, 2025

    @Andrea-Oliveri
    Andrea-Oliveri
    on May 27, 2025
    ContributorAuthor
    More actions

    Good afternoon,
    gentle ping for updates on this issue.
    I think @erlend-aasland wanted to have a look at this too.
    Thank you 😃.

  7. serhiy-storchaka
    added a commit that references this issue on Jun 1, 2025

    gh-134004: Added the reorganize() methods to dbm.sqlite, dbm.dumb and…

    f806463
  8. serhiy-storchaka
    linked a pull request that will close this issuegh-134004: Dbm vacuuming #134028on Jun 1, 2025
  9. serhiy-storchaka
    closed this as completedon Jun 1, 2025
  10. github-project-automation
    moved this to Done in dbm and shelve issueson Jun 1, 2025
  11. Pranjal095
    added a commit that references this issue on Jul 12, 2025

    pythongh-134004: Added the reorganize() methods to dbm.sqlite, dbm.du…

    d730671
  12. taegyunkim
    added a commit that references this issue on Aug 4, 2025

    pythongh-134004: Added the reorganize() methods to dbm.sqlite, dbm.du…

    d7eb5ea
  13. Agent-Hellboy
    added a commit that references this issue on Aug 19, 2025

    pythongh-134004: Added the reorganize() methods to dbm.sqlite, dbm.du…

    a151caa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

    Projects

    • dbm and shelve issues
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.