Module
utils.primitives
Pure utility functions with no Bengal imports.
This sub-package contains foundation utilities that have zero dependencies on other Bengal modules. They can be tested in isolation and are safe to import from anywhere in the codebase without risk of circular dependencies.
Modules:
hashing: Cryptographic hashing for cache keys and fingerprinting
text: Text processing (slugify, truncate, HTML strip)
dates: Date parsing, formatting, and time_ago
types: Type introspection (Optional detection, type names)
sentinel: MISSING singleton for unambiguous missing states
dotdict: Dictionary with dot notation access
lru_cache: Thread-safe LRU cache with optional TTL
Example:
>>> from bengal.utils.primitives import hash_str, slugify, MISSING, LRUCache
>>> key = hash_str("content", truncate=8)
>>> slug = slugify("Hello World!")
>>> if value is MISSING:
... value = default
>>> cache = LRUCache(maxsize=100)