[Python-Dev] Store timestamps as decimal.Decimal objects

Georg Brandl g.brandl at gmx.net
Tue Jan 31 21:49:52 CET 2012

Am 31.01.2012 13:08, schrieb Victor Stinner:

>> This way you don't need to maintain a
>> mapping of strings to classes, and other functions/third party can join in
>> the fun without needing access to the latest canonical mapping. Lastly there
>> will be no confusion or contention for duplicate keys.
> My patch checks isinstance(format, type), format.__module__ and
> format.__name__ to do the "mapping". It is not a direct mapping
> because I don't always call the same method, the implementation is
> completly differenet for each type.
> I don't think that we need user defined timestamp formats. My last
> patch provides 5 formats:
> - int
> - float
> - decimal.Decimal
> - datetime.datetime
> - datetime.timedelta
> (I removed the timespec format, I consider that we don't need it.)

Rather, I guess you removed it because it didn't fit the "types as flags"

As I said in another message, another hint that this is the wrong API design:
Will the APIs ever support passing in types other than these five?  Probably
not, so I strongly believe they should not be passed in as types.


More information about the Python-Dev mailing list