Skip to main content

A high-performance, enterprise-grade Segment Tree implementation for Python

Project description

🌳 Segee

Python 3.12+ MIT License

Lightning-fast range queries with O(log n) performance and modern Python design.

✨ Features

🚀 High Performance - O(log n) range queries and updates
🔒 Type Safe - Complete generic type hints for Python 3.12+
🏢 Enterprise Ready - Comprehensive error handling and validation
🧪 Battle Tested - 152 unit tests with ground truth validation
🐍 Pythonic - Full sequence protocol support (tree[i], len(tree), etc.)
Zero Dependencies - Pure Python with no external requirements

🚀 Quick Start

from segee import SumSegmentTree, MinSegmentTree, MaxSegmentTree

# Sum queries - perfect for range sum problems
sum_tree = SumSegmentTree(1000)
sum_tree[100] = 42
sum_tree[200] = 58
print(sum_tree.sum(100, 201))  # 100

# Min/Max queries - ideal for range minimum/maximum problems  
min_tree = MinSegmentTree(1000)
min_tree[50:55] = [10, 5, 20, 15, 8]
print(min_tree.minimum(50, 55))  # 5

# Custom operations - build your own segment tree
import operator, math
gcd_tree = SegmentTree(100, 0, math.gcd)

📦 Installation

pip install segee

🏗️ Architecture

segee/
├── segment_tree/           # Segment tree implementations
│   ├── segment_tree.py    # Generic segment tree core
│   └── specialized.py     # Sum/Min/Max convenience classes
├── exceptions.py          # Custom exception hierarchy  
└── _types.py             # Type definitions and protocols

📚 Documentation

📄 License

MIT License - see LICENSE for details.


Built with ❤️ for the Python community

🐛 Report Bug✨ Request Feature📖 Documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

segee-0.1.0.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

segee-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file segee-0.1.0.tar.gz.

File metadata

  • Download URL: segee-0.1.0.tar.gz
  • Upload date:
  • Size: 21.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for segee-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ec024c17c9636eb2599680207b01c6b2bc6ab53657af208b72161669af31e194
MD5 450560976caabe727d6906e752f601ae
BLAKE2b-256 9fb8158a2850ac32eff80eb9bdf48ce6325d823842c5ed16b89726e1f362fce7

See more details on using hashes here.

File details

Details for the file segee-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: segee-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for segee-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b299a70f895c4cf15b1fe52bfba962b562a4bfa9f4e97e6846a0bcc0718a7f74
MD5 2613217a189f9078d548e9b165acc048
BLAKE2b-256 9b0da106d09465f58dad4f56bafadb53d77185c89486a6422c8535449c6880cc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page