python-immutable-accumulator

Community

Immutable state accumulators in Python.

Authorshimo4228
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Mutable state accumulation is a common source of bugs, making debugging, reasoning about code, and concurrent execution unpredictable. This pattern uses a frozen dataclass with slots and a tuple to store records so that every update yields a new, immutable instance, eliminating shared mutable state and enabling safer reasoning about state changes.

Core Features & Use Cases

  • Core Pattern: immutable accumulation by returning a new instance from add(), enabled by frozen=True and slots=True dataclasses.
  • Safe totals and iteration: lightweight, hashable containers support straightforward aggregation and traversal.
  • Pydantic Variant: optional model-based variant for environments that rely on Pydantic for validation.
  • Thread-safe and functional style: natural fit for pipelines and parallel processing without side effects.
  • Practical guidance: designed for use in cost tracking, event sourcing, and stateful workflows requiring reproducibility.

Quick Start

Create an empty Accumulator and repeatedly call add() with Record instances to build an immutable sequence.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: python-immutable-accumulator
Download link: https://github.com/shimo4228/claude-code-learned-skills/archive/main.zip#python-immutable-accumulator

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.