Skip to main content

A collection of tiny, reusable Python utilities.

Project description

tuttifrutti

preview

A collection of tiny, lightweight, and highly optimized Python utilities to make your everyday coding sweet and crisp. Fully typed, zero external dependencies, and built with lazy-loading for maximum performance.


Utilities

1. OptionalChain

Tired of guarding deeply nested dictionaries or object lookups with defensive if configurations? OptionalChain brings clean, safe JavaScript-style optional chaining (?.) directly to Python.

from tuttifrutti import OptionalChain

@dataclass
class Course:
    name: str
    level: Literal["Basic", "Intermediate", "Advance"]
    price: int | None


@dataclass
class AppUser:
    name: str | None
    username: str | None
    age: int | None
    courses: list[Course] | None
    meta: dict[str, Any]


@dataclass
class AppResponse:
    data: OptionalChain[AppUser]
    status: int


course1 = Course(name="Python", level="Basic", price=2000)
course2 = Course(name="JS/TS", level="Intermediate", price=3400)
course3 = Course(name="Go", level="Advance", price=None)

app_user = AppUser(
    name="Kunal",
    username=None,
    age=10,
    courses=[course1, course2, course3],
    meta={
        "purchase_day": str(date.today()),
        "coupon": True,
    },
)
app_response = AppResponse(
    data=OptionalChain(app_user),
    status=200,
)

ans: int | None = (
    app_response
    .data
    .courses[0]
    .price
    .map(lambda x: x //12)
    .get()
)
print(ans) # Output: 166


def append_at_sign(username:str)->str:
    return f"{"@"}username"

ans = (
    app_response
    .data
    .username
    .map(append_at_sign)
    .get()
)
print(ans) # Output: None

More tiny utilities are actively cooking and coming soon!

📦 Features

  • ⚡ Ultra Lightweight & Lazy-Loaded: Submodules are only loaded into memory when explicitly called—keeping your application startup lightning fast.
  • 🛡️ Fully Type-Safe: Ships with explicit PEP 561 typing configurations (py.typed) to ensure strict compatibility with tools like mypy and modern IDE autocomplete structures.
  • 🪶 Zero Dependencies: Pure, clean standard-library enhancements.

🚀 Installation

Install tuttifrutti using your favorite Python package manager:

# Using pip
pip install tuttifrutti

# Using uv
uv add tuttifrutti

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

tuttifrutti-0.1.2.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

tuttifrutti-0.1.2-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file tuttifrutti-0.1.2.tar.gz.

File metadata

  • Download URL: tuttifrutti-0.1.2.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tuttifrutti-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9caf53467acdbcc74eaf62a985fe6ae6a6dac9456d673b9e4d12aef5bdf8c8ef
MD5 7d97f09cd5c33cd72b6e75e8bcd1cd05
BLAKE2b-256 72a46d53ab232af12efef12e99cfe2d38afa0fb1fd1c142ecaadc6d82d88f2d5

See more details on using hashes here.

File details

Details for the file tuttifrutti-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: tuttifrutti-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tuttifrutti-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ec14b0a63916f0c6b46e37d67f05c691eba4b6c0ae105f0b32784c700a0e2908
MD5 9dbbb8c829ec5bcc0684a822da15bb7f
BLAKE2b-256 2664a688ba1f71054669205cfe5a8c68ef5d4b953d6f852a958aabb94d4cbe72

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