--- id: btrees version: "6.4" license: ZPL-2.1 license_treatment: unclear maintenance: active --- # BTrees — Scalable persistent object containers License: unclear · Maintenance: active · Downloads: 348.0K/mo ## 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 above — 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 pip install btrees uv add btrees 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_current - Install friction: medium - Maintenance: active - Downloads: 348.0K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags persistent btree data structures, zodb scalable containers, optimistic concurrency btree, persistent object storage, conflict-resolving tree containers, zope btree implementation, scalable persistent mapping, zodb-integration, persistent-storage, concurrent-data-structures [View on SkillFed](https://skillfed.io/packages/btrees) · [View on PyPI](https://pypi.org/project/btrees/)