Created
April 15, 2025 23:28
-
-
Save pschanely/07d97b761e02e2906fb890b9cd66e501 to your computer and use it in GitHub Desktop.
Shared via CrossHair Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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