GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Replace KB unit with KiB by vstinner · Pull Request #4293 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Nov 6, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

kB (kilo byte) unit means 1000 bytes, whereas KiB ("kibibyte")
means 1024 bytes. KB was misused: replace kB or KB with KiB when
appropriate.

Same change for MB and GB which become MiB and GiB.

Change the output of Tools/iobench/iobench.py.

Round also the size of the documentation from 5.5 MB to 5 MiB.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner vstinner added skip issue skip news labels Nov 6, 2017
@vstinner
vstinner requested a review from serhiy-storchaka November 6, 2017 09:42
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Nov 6, 2017
@bedevere-bot bedevere-bot added the awaiting merge label Nov 6, 2017
@vstinner

vstinner commented Nov 6, 2017

Copy link
Copy Markdown
Member Author

https://en.wikipedia.org/wiki/Kibibyte

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner mentioned this pull request Nov 6, 2017
bpo-29659: Expose copyfileobj() length arg for public use #328
Closed
serhiy-storchaka
serhiy-storchaka reviewed Nov 6, 2017
View reviewed changes
Comment thread Lib/distutils/cygwinccompiler.py Outdated

@serhiy-storchaka serhiy-storchaka Nov 6, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure the difference between KB and KiB is important here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Tools/iobench/iobench.py Outdated

@serhiy-storchaka serhiy-storchaka Nov 6, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be kept compatible with both Python 2.6 and Python >= 3.0.

Changing the output format will make harder comparing results between versions.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner Nov 6, 2017

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script is compatible with Python 2.7 (I didn't test Python 2.6).

If the output must be the same with the script in Python 2.7, I can update Python 2.7 as well.

@pitrou: Since you wrote the script, what do you think?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pitrou pitrou Nov 6, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem from me.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread setup.py Outdated

@serhiy-storchaka serhiy-storchaka Nov 6, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is approximate value.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka

serhiy-storchaka commented Nov 6, 2017

Copy link
Copy Markdown
Member

It may be worth to correct also MB and GB (as in f8def28). But not all decimal prefixes can be changed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Nov 6, 2017

Copy link
Copy Markdown
Member Author

It may be worth to correct also MB and GB (as in f8def28).

Done.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka
serhiy-storchaka reviewed Nov 6, 2017
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are cases where a space between digits and unit is missed, like 256KB.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/tools/templates/download.html Outdated

@serhiy-storchaka serhiy-storchaka Nov 6, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure the size in MB and MiB is the same? Are binary prefixes preferenced here?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner Nov 6, 2017

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm quite sure that the file size were compute with an unit of 1024 * 1024 bytes, MiB.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Nov 6, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The size of epub-file in 3.7 is 5.426 MB or 5.175 MiB. 5.5 is closer to 5.426, but in any case this is an approximate estimation. The question is what unit is more human-readable. What units are used by a file manager in Windows and OS X?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner Nov 6, 2017

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What units are used by a file manager in Windows and OS X?

https://blogs.msdn.microsoft.com/oldnewthing/20090611-00/?p=17933

"Explorer is just following existing practice. Everybody (to within experimental error) refers to 1024 bytes as a kilobyte, not a kibibyte."

I prefer KiB rather than KB since KiB is defined as 1024 bytes, whereas KB (or kB) may be 1000 or 1024 bytes.

The size of epub-file in 3.7 is 5.426 MB or 5.175 MiB. 5.5 is closer to 5.426, but in any case this is an approximate estimation.

I don't think that it's interesting to give the file size. If we want to keep it, maybe we should drop digits after the dot.

These numbers are likely outdated, it's very hard to keep them up to date.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Nov 6, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Windows Explorer uses the multiplier 1024 but call it KB, it is good to use binary prefixes here. If it uses the multiplier 1000, perhaps it is better to use decimal prefixes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner Nov 6, 2017

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it uses the multiplier 1000, perhaps it is better to use decimal prefixes.

I'm not aware of any application using decimal prefixes...

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Nov 6, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The volume of hard disks usually is specified with decimal prefixes.

I just have tested, Windows uses binary multipliers (but decimal prefixes), thus it is better to use binary multipliers for getting the same numbers, but with correct binary prefixes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@nicktimko nicktimko Nov 7, 2017

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard drive manufacturers use decimal prefixes, all software I know of uses binary. That's most of the cause behind a 3 TB drive appearing as 2.7 GB to Windows/Linux.

That said, unless you actually care about byte-precision, 5.5 MB is mentally equivalent to 5.5 MiB, or 6 MB, or 5 MB.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka

serhiy-storchaka commented Nov 6, 2017

Copy link
Copy Markdown
Member

Please look also on cases where unit is not separated by a space from a number.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Nov 8, 2017

Copy link
Copy Markdown
Member Author

@serhiy-storchaka: "Please look also on cases where unit is not separated by a space from a number."

Oh, I missed them. Right, there were many of them :-)

I rebased and completed my PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Nov 8, 2017

Copy link
Copy Markdown
Member Author

I found one place in Python where "kB" means 1000 B: the bz2 module. The compression level is the block size in number of 100,000 B. I replaced 100 kB with 100,000 B to prevent any risk of confusion.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Nov 8, 2017

Copy link
Copy Markdown
Member Author

I chose to write "100,000 B" since it's what I found in the official bzip2 documentation:

http://www.bzip.org/1.0.5/bzip2-manual-1.0.5.html#memory-management

The flags -1 through -9 specify the block size to be 100,000 bytes through 900,000 bytes (the default) respectively.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka
serhiy-storchaka approved these changes Nov 8, 2017
View reviewed changes
@serhiy-storchaka

serhiy-storchaka commented Nov 8, 2017

Copy link
Copy Markdown
Member

But writing some numbers (like (2 << 25)) looks strange to me. I would write (1 << 26) or (64 << 20).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
Replace KB unit with KiB
783d6e7
kB (*kilo* byte) unit means 1000 bytes, whereas KiB ("kibibyte")
means 1024 bytes. KB was misused: replace kB or KB with KiB when
appropriate.

Same change for MB and GB which become MiB and GiB.

Change the output of Tools/iobench/iobench.py.

Round also the size of the documentation from 5.5 MB to 5 MiB.
@vstinner

vstinner commented Nov 8, 2017

Copy link
Copy Markdown
Member Author

I replaced "900,000 B" with "900,000 bytes". "B" unit is rarely written like that, usually it's more "bytes".

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
vstinner merged commit 8c663fd into python:master Nov 8, 2017
@bedevere-bot bedevere-bot removed the awaiting merge label Nov 8, 2017
@vstinner
vstinner deleted the kib branch November 8, 2017 22:44
@andresdelfino andresdelfino mentioned this pull request Oct 6, 2018
Update download.html to reflect the unit change #9639
Closed
@vstinner vstinner mentioned this pull request Jul 31, 2019
bpo-18049: Sync thread stack size to main thread size on macOS #14748
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@pitrou pitrou pitrou left review comments
@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes
+1 more reviewer
@nicktimko nicktimko nicktimko left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip issue skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@vstinner @serhiy-storchaka @pitrou @nicktimko @the-knights-who-say-ni @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.