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.
- 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
Full documentation is available at: growgraph.github.io/suthing
pip install suthingfrom 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")from suthing import Timer
with Timer() as t:
# Your code here
pass
print(f"Execution took {t.elapsed_str}")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()from suthing import equals
# Compare nested structures
result = equals(complex_dict1, complex_dict2)- Python 3.10+
- pandas
- PyYAML
- python-dotenv
Contributions are welcome! Please feel free to submit a Pull Request.