skillfed

BTrees

Scalable persistent object containers

btrees v6.4 348.0K downloads/30d#7,345 on PyPI89
License unclear ZPL-2.1 Active released

What it is and what it does

BTrees is a library of persistent container objects built around a modified B-tree data structure, designed to work inside ZODB's optimistic concurrency paradigm. It provides scalable alternatives to standard Python dictionaries and sets that can be stored in a ZODB database, with explicit conflict resolution when concurrent transactions detect conflicts.

The package includes multiple tree variants (OOBTree for object-to-object mappings, IOBTree for integer keys, etc.) and corresponding set types, all optimized for the transactional semantics of ZODB. It depends on persistent (for the base persistent object protocol) and zope.interface (for interface definitions), and is maintained as part of the Zope Foundation ecosystem.

Use it for:

  • Store large, mutable mappings in ZODB that scale better than in-memory dicts for concurrent multi-user applications.
  • Build conflict-aware data structures in ZODB that automatically resolve concurrent modifications without manual locking.
  • Implement persistent sets and ordered collections in a ZODB database with efficient range queries and iteration.
  • Replace standard Python containers in long-lived ZODB transactions where memory efficiency and conflict handling matter.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

BTrees provides persistent, scalable B-tree data structures optimized for ZODB's optimistic concurrency model, with built-in conflict resolution for concurrent access.

Yes, if you are using ZODB and need scalable persistent containers with built-in conflict resolution. The package is mature, actively maintained, and has no known vulnerabilities. Install friction is moderate due to C extension compilation, but wheels are provided for current Python versions. Verify ZPL-2.1 license compatibility before adoption.

Install

btrees on PyPI

pip

pip install btrees

uv

uv add btrees

poetry

poetry add btrees

Installing BTrees

Before you install

Medium install friction due to compiled C extensions across multiple platforms (wheels provided for Python 3.10–3.14 on macOS, Linux, and Windows). Active maintenance with recent release (107 days ago) and ongoing platform support additions.

License in practice

Licensed under ZPL-2.1 (Zope Public License 2.1); license treatment marked unclear in metadata, so verify compatibility with your project's licensing requirements before use.

Quickstart

pip install btrees

from BTrees.OOBTree import OOBTree
from persistent import Persistent

tree = OOBTree()
tree['key'] = 'value'

Requires Python 3.10 or later; C extensions will compile on install if wheels are unavailable for your platform.

Verify before relying

  • Actual performance characteristics and scalability limits compared to standard Python dicts or other persistent stores.
  • Whether the C extension is required or if pure Python fallback is acceptable for your use case.
  • Specific ZODB version compatibility and integration patterns beyond basic container usage.

Package facts

License ZPL-2.1 (unclear)
Python support supports the current Python release (>=3.10)
Install friction medium — platform-specific wheel
Runtime dependencies 2 — persistent, zope.interface
Maintenance actively maintained — 107 days since the last release
Last repo commit
First released
Downloads 348,006/month — #7,345 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: btrees-6.4-cp310-cp310-macosx_10_9_x86_64.whl; btrees-6.4-cp310-cp310-macosx_11_0_arm64.whl; btrees-6.4-cp310-cp310-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl; btrees-6.4-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; btrees-6.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; btrees-6.4-cp310-cp310-win_amd64.whl; btrees-6.4-cp311-cp311-macosx_10_9_x86_64.whl; btrees-6.4-cp311-cp311-macosx_11_0_arm64.whl; btrees-6.4-cp311-cp311-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl; btrees-6.4-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; btrees-6.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; btrees-6.4-cp311-cp311-win_amd64.whl; btrees-6.4-cp311-cp311-win_arm64.whl; btrees-6.4-cp312-cp312-macosx_10_9_x86_64.whl; btrees-6.4-cp312-cp312-macosx_11_0_arm64.whl; btrees-6.4-cp312-cp312-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl; btrees-6.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; btrees-6.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; btrees-6.4-cp312-cp312-win_amd64.whl; btrees-6.4-cp312-cp312-win_arm64.whl

Development Status :: 6 - MatureFramework :: ZODBIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: DatabaseTopic :: Software Development :: Libraries :: Python Modules

Tags

persistent btree data structureszodb scalable containersoptimistic concurrency btreepersistent object storageconflict-resolving tree containerszope btree implementationscalable persistent mapping
zodb-integrationpersistent-storageconcurrent-data-structures

More Python Modules packages