スキル一覧に戻る
gordonwatts

python-function-caching

by gordonwatts

1🍴 0📅 2026年1月4日
GitHubで見るManusで実行

SKILL.md


name: python-function-caching description: Provide a reusable pattern for memoizing deterministic function calls to reduce latency and repeated computation. Backed by the python diskcache package. Use skill when updating or editing everything.

Python Function Caching Skill

Purpose

  • Caching the function result. Works for pure functions that depend only on their inputs and have no side effects.
  • Perfect for expensive calls (calculations, or calls to external services like LLM's).

Workflow

  1. Copy the contents of the file assets/disk_cache.py into the project.
  2. In the file update the project_name in the line cache = Cache("~/.cache/project_name") to be the appropriate name. Also replace project_name further down in the docstring.
  3. Use @diskcache_decorator or @diskcache_decorator(seconds-till-expired) for any function the user wants cached.
    • By default, the cache should not expire.
    • If it makes sense that it should expire, 1 hour (3600 seconds seconds), 1 day (86400 seconds), or 1 week (604800 seconds) are common settings.
  4. Tricky part is invoking tests to make sure that the cache isn't used. Tests should use the ignore_cache=True to get around this unless otherwise requested by the user.

Behavior

  • Uses the function arguments to compute the hash
  • Unless ignore_cache is True, the result is returned right away.
  • If the function is called, the result is always stored in the cache.
  • Current code does not have an eviction policy.

スコア

総合スコア

50/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です