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)

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.13.0.tar.gz (11.3 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.13.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyutilkit-0.13.0.tar.gz
  • Upload date:
  • Size: 11.3 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.13.0.tar.gz
Algorithm Hash digest
SHA256 f93c888949c0e7fbbf1a5138c32a265b43250640bee9d5ecc2e5b105481c7c2f
MD5 c4946f3de63311b3f3c34249931f9ec7
BLAKE2b-256 c698034e76ca20e59eadbd06ccc480fa13bf834f91913e7227efa184379e492c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyutilkit-0.13.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 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.13.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f56c196f1ded03352b7693d7f0e75998f22ef0921c6d2d61a488aedb544cd758
MD5 2f467e12a762c64a6846cccc8e701cf1
BLAKE2b-256 eef87318eecb1b38205f100c62278d5601851fb80eb0a743d9617e8bcc70b6a4

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.13.0 This release

2 files

0.12.0

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