Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make "<Binary: 2427344 bytes>" easier to read #1712

Closed
simonw opened this issue Apr 12, 2022 · 3 comments
Closed

Make "<Binary: 2427344 bytes>" easier to read #1712

simonw opened this issue Apr 12, 2022 · 3 comments

Comments

@simonw
Copy link
Owner

simonw commented Apr 12, 2022

Binary: 2,427,344 bytes would be nicer - even better, include a tooltip showing that size translated using this function:

def format_bytes(bytes):
current = float(bytes)
for unit in ("bytes", "KB", "MB", "GB", "TB"):
if current < 1024:
break
current = current / 1024
if unit == "bytes":
return f"{int(current)} {unit}"
else:
return f"{current:.1f} {unit}"

CleanShot 2022-04-12 at 11 15 04@2x

@simonw
Copy link
Owner Author

simonw commented Apr 12, 2022

image

@simonw
Copy link
Owner Author

simonw commented Apr 12, 2022

I'm not going to show the tooltip if the formatted number is in bytes.

@simonw simonw changed the title Make "<Binary: 2427344 bytes>" easier to understand Make "<Binary: 2427344 bytes>" easier to read Apr 12, 2022
@simonw simonw closed this as completed in 0bc5186 Apr 12, 2022
@simonw
Copy link
Owner Author

simonw commented Apr 12, 2022

simonw added a commit that referenced this issue May 2, 2022
simonw added a commit that referenced this issue Aug 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant