π ThreadFactory 1.2.4 β Smarter Collections, Stronger Control
High-performance thread-safe collections, lifecycle-aware Work objects, a full benchmarking suite, and the foundation of modular concurrency for Python 3.13+ (Free Threading).
While active development on ThreadFactory is paused temporarily, the team is now building Melder, a powerful DI and composition framework designed to work seamlessly with these primitives.
π [1.2.4] - 2025-05-02
π Classes Added
ConcurrentSet
- A fully thread-safe
setimplementation designed for high read and concurrent write workloads. - Supports full set algebra:
union,intersection,difference,symmetric_difference, with both standard and in-place forms. - Includes:
freeze()mode to make the structure lock-free for reads.batch_update()for atomic composite operations.- Functional access (
map,filter,reduce).
- Integrates cleanly with Python idioms:
with ConcurrentSet(...) as s:enables atomic scoped access.- Implements
IDispose, supporting proper lifecycle cleanup.
β New Features
π Set Algebra + Operators
- Standard operations:
|,&,-,^ - In-place versions:
|=,&=,-=,^= - Method equivalents:
union(),intersection(), etc.
π§ Functional Utilities
- Built-in
map(func),filter(func), andreduce(func)on the set β thread-safe and iterable-aware.
π§ Freeze Mode
- New
freeze()method added to:ConcurrentSetConcurrentListConcurrentDict
- When frozen:
- All mutations are blocked.
- Reads (iteration, contains, length) become lock-free, improving performance.
- Unfreeze manually or via internal mechanisms.
π§΅ Lock-Aware Reads
- Smart internal handling avoids unnecessary locking:
__iter__,__contains__,__len__, and copies are optimized based on freeze state.
π Atomic Batch Operations
batch_update(func)ensures thread-safe bulk changes under a single lock pass.
π Fixes
-
ConcurrentQueueandConcurrentStack:peek()now usestry/finallyto guarantee lock release even when exceptions are raised.
-
Clarified locking strategy and lifecycle handling across
concurrent_coreclasses via enhanced docstrings.
π Changes
-
License upgraded from MIT to Apache 2.0
- Enforces better attribution.
- Improves corporate compliance and future integration safety.
-
NOTICE File
- Now includes formal third-party acknowledgments.
-
Disposal Standardization
- All disposable types implement a common
IDisposeinterface with internal.disposedflags anddispose()methods.
- All disposable types implement a common
π§ Project Status
Development on ThreadFactory is not abandoned β itβs currently paused as the team shifts focus to a companion framework:
Melder β A dependency injection and object composition system that integrates deeply with
ThreadFactory.
Melder will allow you to:
- Compose concurrent flows using declarative bindings.
- Control lifecycles with Work + Scope-aware systems.
- Scale from functions to full orchestrated pipelines.
ThreadFactory will resume updates once Melder stabilizes, with both designed to work together in the long term.
π¦ Install or Upgrade
pip install --upgrade threadfactory