Skip to main content

Small Useful Things : python package for convenient primitives

Project description

SUThing

SUThing /ˈsu.θɪŋ/ or /ˈsʌ.θɪŋ/ (Some Useful Things) is a collection of useful classes and decorators.

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

Python PyPI version License: MIT pre-commit pytest

Features

  • File Handling: one-line file reading/wriing with file format infererence from provided extension (YAML, JSON, CSV, pickle, gz etc.)
  • Performance Measurement: Simple timer utilities and profiling decorators
  • Data Comparison: Deep comparison of nested data structures
  • Error Handling: Decorators for secure function execution and error tracking

Installation

pip install suthing

Usage Examples

File Handling

from suthing import FileHandle, FileType

# Read YAML file
data = FileHandle.load(fpath="config.yaml")

# Write compressed JSON
# file type inferred from extension
FileHandle.dump(data, "output.json.gz")

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 profile, SProfiler

profiler = SProfiler()

@profile(_argnames="input_size")
def my_function(input_size):
    # Function code
    pass

# Run with profiler
my_function(input_size=100, _profiler=profiler)

# View results
stats = profiler.view_stats()

Deep Comparison

from suthing import equals

# Compare nested structures
result = equals(complex_dict1, complex_dict2)

Requirements

  • Python 3.10+
  • pandas
  • PyYAML
  • python-dotenv

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

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

Source Distribution

suthing-0.4.0.tar.gz (80.2 kB view details)

Uploaded Source

Built Distribution

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

suthing-0.4.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file suthing-0.4.0.tar.gz.

File metadata

  • Download URL: suthing-0.4.0.tar.gz
  • Upload date:
  • Size: 80.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for suthing-0.4.0.tar.gz
Algorithm Hash digest
SHA256 7002afa2b3df438df9413b5d970921a23d8da8a36b5472a28ec2c38835ea8f45
MD5 19180a1202b3bfa347220bdd4b3b50be
BLAKE2b-256 468a68e2b4200ff40eed399715e3fd4379dab5942be3967a8dff8d45852fc74a

See more details on using hashes here.

File details

Details for the file suthing-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: suthing-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for suthing-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 575d1c834fe321fd5a2f18545dd04cbef2f004891ecc8cfe4b3740e541560594
MD5 c521b1ed3f016b12db9af401008a2974
BLAKE2b-256 1044b0f39ffd0da651dd475f1f351b0b1936c3a14f4483197844e6c9f51e3756

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page