Skip to content

Instantly share code, notes, and snippets.

To see what was added in the gh-pages branch compared to master in linguist repo:

https://github.com/octocat/linguist/compare/master...gh-pages

File Size Parser

A simple Python function to parse human-readable file size strings into their byte values.

Function: filesizep(s: str) -> float

Parses a file size string with optional unit suffix and returns the size in bytes.

Features:

  • Supports numeric values without units (assumed to be bytes)
class SmartGet:
"""Handles dynamic attribute computation and caching using '_get_*' methods.
This enables lazy evaluation where attributes are:
1. Computed only when first accessed (via specially named '_get_attr' methods)
2. Automatically cached for subsequent accesses
3. Transparent to the caller (used like normal attributes)
Typical usage:
class DataLoader(LazyAttributes):