#7652 closed defect (fixed)
File attachment size uses units incorrectly
Reported by: | Owned by: | Remy Blank | |
---|---|---|---|
Priority: | normal | Milestone: | 0.11.2 |
Component: | web frontend | Version: | 0.12dev |
Severity: | minor | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
Currently, Trac would report a 100,000 byte file as "97.7 kB", dividing by 1024.
It uses a lowercase "k" in the unit, though, which implies dividing by 1000 as in the SI standard, so it would normally be "100.0 kB".
Capitalized "KB" is sometimes used to mean "1024 bytes", like "97.7 KB", but this usage is non-standard and officially deprecated; you're supposed to write binary kilobytes (dividing by 1024) as "97.7 KiB".
I've made two patches, one for decimal "100.0 kB", and one for binary "97.7 KiB". I personally think file sizes should be measured in 1000s, but dividing by 1024 is traditional for some odd reason, and used in other bug trackers like Launchpad, so you can go with what you prefer.
Also replaced a while loop with a for loop in an attempt to be "pythonic".
Attachments (2)
Change History (15)
by , 16 years ago
Attachment: | decimal_units.diff added |
---|
follow-ups: 2 3 comment:1 by , 16 years ago
Milestone: | → 0.11.3 |
---|---|
Owner: | set to |
That seems to be kind of a religious issue, but strictly speaking, you're right.
comment:2 by , 16 years ago
Replying to rblank:
That seems to be kind of a religious issue, but strictly speaking, you're right.
However virtually not software uses KiB notation, nor divide by 1000 (but hard driver makers)
I'd rather see this ticket closed as 'wontfix', or targeted to a very far milestone such as 2.0, and implemented once most of the software out there actually use KiB.
I agree that KiB is the proper notation, but very few people actually use it.
When "ls" and other standard tools use KiB or divide by 1000, it is ok for Trac to follow the official notation. In the meantime, it would be confusing, as most people expect 1 kilobyte to be 1024 bytes, i.e. 210, not 103.
See ls -lh
: it uses "K", not "Ki" and divide by 210.
So let Trac follows the common, usual, pragmatical rule.
follow-up: 6 comment:3 by , 16 years ago
Replying to rblank:
That seems to be kind of a religious issue, but strictly speaking, you're right.
More of a sloppiness issue, really. :)
Replying to eblot:
I'd rather see this ticket closed as 'wontfix', or targeted to a very far milestone such as 2.0, and implemented once most of the software out there actually use KiB.
There's quite a bit of software that uses it, actually, and more that uses k to mean 1000 (common usage in most fields).
Bug trackers like Launchpad, bugs.mysql.com, and flyspray all use KiB notation, for instance. There are probably others I don't know about.
I agree that KiB is the proper notation, but very few people actually use it.
When "ls" and other standard tools use KiB or divide by 1000,
ls —si
In the meantime, it would be confusing, as most people expect 1 kilobyte to be 1024 bytes, i.e. 210, not 103.
You're probably right that most developers think that way, but most "people" certainly think of k- as 1000.
follow-up: 5 comment:4 by , 16 years ago
Heh, that's exactly what I meant with "a religious issue":
- Virtually everybody is able to understand all of the notations, even the one that is "wrong", so
- it's rather cosmetic and really not that important, but
- there are strong opinions on both sides
Personally, I don't really care, so I would tend to err on the side of correctness, but that's only me.
<flamebait>
We could add a configuration option for that, couldn't we?
</flamebait>
/me ducks out of sight ;-)
comment:5 by , 16 years ago
Replying to rblank:
- Virtually everybody is able to understand all of the notations, even the one that is "wrong"
Well, I was thrown off because you use lowercase "kB", but mean 1024. I don't think anyone does that. Usually the "wrong" usage is capital "KB". When I see lowercase k I think SI.
follow-up: 7 comment:6 by , 16 years ago
Replying to endolith@…:
There's quite a bit of software that uses it, actually, and more that uses k to mean 1000 (common usage in most fields).
There is software that uses it, that's right. The question is: what's the ratio?
In the meantime, it would be confusing, as most people expect 1 kilobyte to be 1024 bytes, i.e. 210, not 103.
You're probably right that most developers think that way, but most "people" certainly think of k- as 1000.
Two points here:
- Trac is mostly targeted at developers, or people who deal with software
- What will happen when (regular) people that are used to see implicit "KiB" in their file explorer upload a file to Trac, or download a file from Trac, and see a file that does not seem to have the same size on their machine than it is shown in the Trac page ?
If this request is ever implemented, please leave it as an option. I think it will bring more issues than it can solve - at least for now. Still -1 IMHO.
As a final note, the default settings for the 'major' OSes are:
- Mac OS X (Finder) shows "KB" and use 210, i.e. "KiB"
- WinXP SP3 (Explorer) shows "KB" and use 210, i.e. "KiB"
- Linux 2.6 (KDE) shows "KB" and use 210, i.e. "KiB"
I think Trac should stick with the common notation rather than implements a more valid, but still theoretical notation.
follow-up: 8 comment:7 by , 16 years ago
Replying to eblot:
There is software that uses it, that's right. The question is: what's the ratio?
I don't know, but Launchpad, mySQL, and Flyspray bug trackers all use the "KiB" standard units, and they have plenty of users, so they at least don't think it's too confusing to use.
What will happen when (regular) people
Regular people think that k- means 1000. They're only familiar with kilograms, kilometers, etc. They aren't aware of the "K- = 1024" convention at all, so using it is confusing. That's why the standard exists.
Developers are more familiar with the K = 1024 convention, so it doesn't bother me too much to use the wrong units in a bug tracker, but using lowercase "kB" to mean 1024 is especially wrong. If you're going to intentionally choose to use the wrong units, at least use "KB" instead. I'd prefer it use the standard units, though, and avoid the confusion altogether.
- Linux 2.6 (KDE) shows "KB" and use 210, i.e. "KiB"
KDE yes, but not Linux itself:
When the Linux kernel boots and says hda: 120064896 sectors (61473 MB) w/2048KiB Cache the MB are megabytes and the KiB are kibibytes.
(from Linux Programmer's Manual)
follow-up: 9 comment:8 by , 16 years ago
Replying to endolith@…:
… but using lowercase "kB" to mean 1024 is especially wrong. If you're going to intentionally choose to use the wrong units, at least use "KB" instead.
I think we can agree on the above.
follow-up: 10 comment:9 by , 16 years ago
Replying to cboos:
… but using lowercase "kB" to mean 1024 is especially wrong. If you're going to intentionally choose to use the wrong units, at least use "KB" instead.
I think we can agree on the above.
Yes, I do agree: it should be KB, not kB.
comment:11 by , 16 years ago
Milestone: | 0.11.3 → 0.11.2 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
All right, changed kB
into KB
in [7612].
follow-up: 13 comment:12 by , 16 years ago
Augh…I much prefer kB and the understanding that in the context of bytes it refers to 210 instead of 1000 (hard drive makers being the only exception I've ever seen in the real world). None of this KiB or KB silliness.
But as Remy said, it's a religious issue. Ah well, it's not important.
comment:13 by , 16 years ago
Replying to ebray:
Augh…I much prefer kB and the understanding that in the context of bytes it refers to 210 instead of 1000
Me too. This should be the only way file sizes are measured. The KB = 1024 convention serves absolutely no purpose but to confuse people (and keeps backwards compatibility with MS-DOS, I guess?)
http://lpar.ath0.com/2008/07/15/si-unit-prefixes-a-plea-for-sanity/
(hard drive makers being the only exception I've ever seen in the real world).
The Linux kernel uses it, as shown above, lots of software like the apt package manager uses it (kB = 1000 B). All networking hardware (56K modem is 56,000 bit/s). Almost all media measurements, like DVDs, Blu-ray, etc. (4.7 GB DVD is ~4,700,000,000 B) Bit rates for things like mp3s (128 kbps mp3 is 128,000 bit/s). etc etc etc
But there are still people like the ones in this thread who insist on confusing users for no good reason. :)
Decimal version