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

Georg Brandl g.brandl at gmx.net
Tue Jan 31 07:22:08 CET 2012

Am 31.01.2012 00:50, schrieb Matt Joiner:
> Sounds good, but I also prefer Alexander's method. The type information is
> already encoded in the class object. 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.

Sorry, I don't think it makes any sense to pass around classes as flags.
Sure, if you do something directly with the class, it's fine, but in this case
that's impossible. So you will be testing

  if format is datetime.datetime:
  elif format is decimal.Decimal:

which has no advantage at all over

  if format == "datetime":
  elif format == "decimal":

Not to speak of formats like "timespec" that don't have a respective class.
And how do you propose to handle the extensibility you speak of to work?


More information about the Python-Dev mailing list