This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients Alexander.Belopolsky, Arfrever, belopolsky, ericography, jcea, khenriksson, larry, lars.gustaebel, loewis, mark.dickinson, nadeem.vawda, r.david.murray, rhettinger, rosslagerwall, skrah, vstinner
Date 2012-01-30.03:04:29
SpamBayes Score 6.217249e-15
Marked as misclassified No
Message-id <1327892670.69.0.18680052418.issue11457@psf.upfronthosting.co.za>
In-reply-to
Content
I don't like the idea of adding new fields to os.stat() *by default* because it may break backward compatibility. And if the new fields are decimal.Decimal objects, the module has to be imported and it means that any call to os.stat() would be slower just to provide timestamps with a finer resolution: this is not acceptable if you just want to check if a file exists.

In the issue #13882, I propose to add a format argument to functions getting time (time.time(), time.clock(), etc.). My patch doesn't change the default type, but add a "decimal" format to get time as a decimal.Decimal object.

The option (format) value is a string to be able to add other formats without having to change the API later:

 - "decimal": decimal.Decimal object
 - "datetime": datetime.datetime object
 - "tuple": low-level value, (intpart: int, floatpart: int, divisor: int)
 - "float128"
 - etc.

For os.stat(), the optional argument can be called "timestamp".

So if you want timestamps in the best available resolution, use timestamp="decimal". If you prefer the datetime API, use timestamp="datetime". If you don't care of timestamps, just call os.stat() without setting the timestamp option ;-)

We might add a registry to add user-defined types, but the "tuple" format should be enough. (I don't know if we need to expose the low level "tuple" format.)
History
Date User Action Args
2012-01-30 03:04:31vstinnersetrecipients: + vstinner, loewis, rhettinger, jcea, mark.dickinson, belopolsky, lars.gustaebel, larry, nadeem.vawda, Arfrever, r.david.murray, skrah, Alexander.Belopolsky, rosslagerwall, khenriksson, ericography
2012-01-30 03:04:30vstinnersetmessageid: <1327892670.69.0.18680052418.issue11457@psf.upfronthosting.co.za>
2012-01-30 03:04:30vstinnerlinkissue11457 messages
2012-01-30 03:04:29vstinnercreate