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.10 or higher
  • No external dependencies (tzdata is automatically installed on Windows)

Links

Download files

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

Source Distribution

pyutilkit-0.12.0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

pyutilkit-0.12.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file pyutilkit-0.12.0.tar.gz.

File metadata

  • Download URL: pyutilkit-0.12.0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for pyutilkit-0.12.0.tar.gz
Algorithm Hash digest
SHA256 9dd54707574ea73869dd255c8c77dc1a9f5e2f2e1be4e65a5eb56250c1438b8f
MD5 508f8197353b1d9cca9dc6a894a6bc25
BLAKE2b-256 afd8f83137d6f2adbc43087bfbbd44369363db10f6cec4a994611c2126545e3a

See more details on using hashes here.

File details

Details for the file pyutilkit-0.12.0-py3-none-any.whl.

File metadata

  • Download URL: pyutilkit-0.12.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for pyutilkit-0.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 91046e377d00dc2d2f6262a4a3b91d879b3e66a575d62c526b292ed8cadca3db
MD5 4684ed862ef4bd06055ff6ecd6b5e115
BLAKE2b-256 5dae4e140fb47598b5c6b396ca455717a5f8ede3bf0fee76305f78ce686541c2

See more details on using hashes here.

Release history Release notifications | RSS feed

0.13.0

2 files

This release

0.12.0 This release

2 files

0.11.0.post1

2 files

0.11.0

2 files

0.10.0

2 files

0.9.0

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 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