GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - growgraph/suthing: Small Useful Things : python package for convenient primitives

BranchesTags
Open more actions menu

Latest commit

 

History

77 Commits
77 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
.vscode
.vscode
 
 
docs
docs
 
 
suthing
suthing
 
 
test
test
 
 
.gitignore
.gitignore
 
 
.isort.cfg
.isort.cfg
 
 
.pre-commit-config.yaml
.pre-commit-config.yaml
 
 
.pylintrc
.pylintrc
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
mkdocs.yml
mkdocs.yml
 
 
pyproject.toml
pyproject.toml
 
 
uv.lock
uv.lock
 
 

Repository files navigation

SUThing suthing logo

SUThing /ˈsu.θɪŋ/ or /ˈsʌ.θɪŋ/ (Some Useful Things) is a collection of small, dependable utilities.

A Python utility package providing tools for file handling, timing, profiling, data comparison and hashing.

Python PyPI version PyPI Downloads License: MIT pre-commit

Features

  • File Handling: one-line reading and writing with the format inferred from the extension (YAML, JSON, JSON Lines, CSV/TSV, text, dotenv, pickle), transparent .gz/.bz2/.xz/.zst compression, atomic writes and streaming reads
  • Timing and Profiling: a Timer context manager/decorator and opt-in function profiling with per-key statistics
  • Data Comparison: deep diff of nested structures that reports the path of every difference, with numeric tolerance and order-insensitive matching
  • Hashing: stable hashes of JSON-like values, text, files and directory trees
  • Small Helpers: batched, slugify, to_jsonable, env_flag, setup_logging, utc_now_iso

Documentation

Full documentation is available at: growgraph.github.io/suthing

Installation

pip install suthing

Usage Examples

File Handling

from suthing import FileHandle, FileType

# format inferred from the extension
data = FileHandle.load("config.yaml")

# compressed by suffix, written atomically
FileHandle.dump(data, "output.json.gz")

# data shipped inside a package
defaults = FileHandle.load_resource("mypkg.data", "defaults.yaml")

# explicit format for an unrecognised extension
secret = FileHandle.load("token.secret", how=FileType.TXT)

Timing Code

from suthing import Timer

with Timer() as t:
    # Your code here
    pass
print(f"Execution took {t.elapsed_str}")

Profiling Functions

from suthing import Profiler, profiled


@profiled(key_args="input_size")
def my_function(input_size): ...


with Profiler() as prof:
    my_function(100)

stats = prof.summary()  # {"my_function(input_size=100)": ProfileStats(...)}

Deep Comparison

from suthing import diff, equals

equals(expected, actual)  # bool
for d in diff(expected, actual):  # where they differ
    print(d)  # $.users[1].name: values differ (expected='Bob', actual='Rob')

Requirements

  • Python 3.11+
  • pandas (imported only for CSV/TSV)
  • PyYAML
  • python-dotenv
  • optional: zstandard for .zst files (pip install "suthing[zstd]")

Development

uv sync --group dev
uv run pytest test
uv run ty check suthing test

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. See Contributing for the full workflow.

About

Small Useful Things : python package for convenient primitives

growgraph.github.io/suthing

Resources

Readme
MIT license

Contributing

Contributing
Activity
Custom properties

Stars

6 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.