ctime: I don't think that word means what you think it means.

The stat module uses the "st_ctime" slot to hold two kinds of values which are semantically different and which are frequently confused with one another. It chooses which kind of value to put in there based on platform -- Windows gets the file creation time and all other platforms get the "ctime". The only sane way to use this API is then to switch on platform: if platform.system() == "Windows": metadata["creation time"] = s.st_ctime else: metadata["unix ctime"] = s.st_ctime (That is an actual code snippet from the Allmydata-Tahoe project.) Many or even most programmers incorrectly think that unix ctime is file creation time, so instead of using the sane idiom above, they write the following: metadata["ctime"] = s.st_ctime thus passing on the confusion to the users of their metadata, who may not be able to tell on which platform this metadata was created. This is the situation we have found ourselves in for the Allmydata-Tahoe project -- we now have a bunch of "ctime" values stored in our filesystem and no way to tell which kind they were. More and more filesystems such as ZFS and Mac HFS+ apparently offer creation time nowadays. I propose the following changes: 1. Add a "st_crtime" field which gets populated on filesystems (Windows, ZFS, Mac) which can do so. That is hopefully not too controversial and we could proceed to do so even if the next proposal gets bogged down: 2. Add a "st_unixctime" field which gets populated *only* by the unix ctime and never by any other value (even on Windows, where the unix ctime *is* available even though nobody cares about it), and deprecate the hopelessly ambiguous "st_ctime" field. You may be interested in http://allmydata.org/trac/tahoe/ticket/628 ("mtime" and "ctime": I don't think that word means what you think it means.) where the Allmydata-Tahoe project is carefully unpicking the mess we made for ourselves by confusing ctime with file-creation time. This is ticket http://bugs.python.org/issue5720 . Regards, Zooko

Zooko Wilcox-O'Hearn wrote:
1. Add a "st_crtime" field which gets populated on filesystems (Windows, ZFS, Mac) which can do so.
"crtime" looks rather too similar to "ctime" for my liking. People who think that the "c" in "ctime" means "creation" are still likely to confuse them. Why not give it a more explicit name, such as "st_creationtime"? -- Greg

On Sun, 14 Jun 2009 10:40:53 am Greg Ewing wrote:
Zooko Wilcox-O'Hearn wrote:
1. Add a "st_crtime" field which gets populated on filesystems (Windows, ZFS, Mac) which can do so.
"crtime" looks rather too similar to "ctime" for my liking. People who think that the "c" in "ctime" means "creation" are still likely to confuse them.
Why not give it a more explicit name, such as "st_creationtime"?
Speaking as somebody who thought the c in ctime meant creation, I'm +1 on this proposal with Greg's modification. -- Steven D'Aprano

Steven D'Aprano wrote:
On Sun, 14 Jun 2009 10:40:53 am Greg Ewing wrote:
1. Add a "st_crtime" field which gets populated on filesystems (Windows, ZFS, Mac) which can do so. "crtime" looks rather too similar to "ctime" for my
Zooko Wilcox-O'Hearn wrote: liking. People who think that the "c" in "ctime" means "creation" are still likely to confuse them.
Why not give it a more explicit name, such as "st_creationtime"?
My this bike-shed looks a bit greenish. How about: creation_time or, at least, st_creation_time
Speaking as somebody who thought the c in ctime meant creation, I'm +1 on this proposal with Greg's modification.
--Scott David Daniels Scott.Daniels@Acm.Org
participants (4)
-
Greg Ewing
-
Scott David Daniels
-
Steven D'Aprano
-
Zooko Wilcox-O'Hearn