Skip to content

Instantly share code, notes, and snippets.

@pschanely
Created April 15, 2025 23:28
Show Gist options
  • Save pschanely/07d97b761e02e2906fb890b9cd66e501 to your computer and use it in GitHub Desktop.
Save pschanely/07d97b761e02e2906fb890b9cd66e501 to your computer and use it in GitHub Desktop.
Shared via CrossHair Playground
import json
BYTES_PER_ENTITY = 507
def estimate_storage(entity_count: int) -> str:
"""
pre: 0 <= entity_count < 1000
post: len(__return__) < 19
"""
kib = entity_count * BYTES_PER_ENTITY
size = f"{kib}kib" if kib < 1024 else f"{kib // 1024}mib"
return json.dumps({"size": size})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment