Skip to main content

pyutilkit: python's missing batteries

build lint tests license codecov readthedocs pypi downloads build automation: yam Lint: ruff

Python has long maintained the philosophy of "batteries included", providing users with a rich standard library that avoids the need for third-party tools for most tasks. Some packages are so common they have achieved similar status to the standard library. Yet, certain utilities are reimplemented across countless projects. This lightweight library, with minimal dependencies, aims to eliminate that repetition.

Quick Start

Install pyutilkit:

pip install pyutilkit

Or with uv (recommended for speed):

uv pip install pyutilkit

Basic usage example:

from pyutilkit.date_utils import now
from pyutilkit.timing import Stopwatch
from pyutilkit.term import SGRString, SGRCodes

# Get current time in any timezone
from zoneinfo import ZoneInfo

tokyo_time = now(ZoneInfo("Asia/Tokyo"))
print(f"Current time in Tokyo: {tokyo_time}")

# Measure execution time
stopwatch = Stopwatch()
with stopwatch:
    # Your code here
    result = sum(range(1000000))
print(f"Computation took: {stopwatch.elapsed}")

# Colorful terminal output
success = SGRString("✓ Task completed", params=[SGRCodes.GREEN, SGRCodes.BOLD])
success.print()

Key Features

  • 🕐 Timezone Utilities: Robust datetime handling with cross-platform timezone support, ISO parsing (including Zulu timezone), and seamless timezone conversion
  • ⏱️ High-Precision Timing: Nanosecond-precision timing with human-readable formatting, lap tracking, and stopwatch functionality
  • 🎨 Terminal Formatting: ANSI color codes with smart TTY detection, automatic style stripping for piped output, and convenient header formatting
  • 🛡️ Error Handling: Elegant exception handling decorator that logs errors and returns defaults instead of raising exceptions
  • 📁 File Utilities: Efficient SHA-256 file hashing with buffered reading for large files
  • 🚀 Subprocess Enhancement: Run external commands with real-time output streaming, automatic timing, and structured results
  • 🔧 Design Patterns: Thread-safe Singleton metaclass implementation
  • ✨ Zero Dependencies: Pure Python using only standard library (except optional tzdata on Windows)
  • 🧪 Fully Tested: 100% test coverage with comprehensive type annotations

Documentation

Requirements

  • Python 3.11 or higher
  • No external dependencies (tzdata is automatically installed on Windows)

Metadata

Release files for pyutilkit 0.13.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyutilkit 0.13.0
File Size Uploaded
pyutilkit-0.13.0.tar.gz 11.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyutilkit 0.13.0
File Interpreter ABI Platform
pyutilkit-0.13.0-py3-none-any.whl Python 3 none any Details

Total release size: 24.4 kB

Release files / pyutilkit-0.13.0.tar.gz

Download URL pyutilkit-0.13.0.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f93c888949c0e7fbbf1a5138c32a265b43250640bee9d5ecc2e5b105481c7c2f
BLAKE2b-256 checksum
How to use checksums
c698034e76ca20e59eadbd06ccc480fa13bf834f91913e7227efa184379e492c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pyutilkit-0.13.0-py3-none-any.whl

Download URL pyutilkit-0.13.0-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f56c196f1ded03352b7693d7f0e75998f22ef0921c6d2d61a488aedb544cd758
BLAKE2b-256 checksum
How to use checksums
eef87318eecb1b38205f100c62278d5601851fb80eb0a743d9617e8bcc70b6a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.13.0 This release

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page