[Python-Dev] proposal: add basic time type to the standard library

Jim Fulton jim@zope.com
Tue, 26 Feb 2002 09:04:27 -0500


Guido van Rossum wrote:
> 
> >     http://effbot.org/ideas/time-type.htm
> >
> > I can produce PEP and patch if necessary.
> 
> Yes, a PEP, please!  Jim Fulton has been asking for this for a long
> time too.  His main requirement is that timestamp objects are small,
> both in memory and as pickles, because Zope keeps a lot of these
> around. 

I also need time-zone support.

> They are currently represented either as long ints (with a
> little under 64 bits) or as 8-byte strings. 

ZODB has a TimeStamp type that uses a 32-bit unsigned integer 
to store year, month,, day, hour, and minute in a way that makes it dirt
simple to extract a component.  It uses a 32-bit integer to store
seconds in units of 60/2**32 seconds.

This type isn't appropriate for general use because it only allows
dates later than Dec 31, 1899.

> A dedicated timestamp
> object could be smaller than that.

A type that only needed minute precision could easily be expressed
with 32-bits. Of course, the two-word object overhead makes the difference
between 32-bits and 64-bits rather unexciting.
 
> Your idea of a base type (which presumably standarizes at least one
> form of representation) sounds like a breakthrough that can help
> satisfy different other needs.

I agree.

Jim

--
Jim Fulton           mailto:jim@zope.com       Python Powered!        
CTO                  (888) 344-4332            http://www.python.org  
Zope Corporation     http://www.zope.com       http://www.zope.org