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.

classification
Title: datetime module should use int32_t for date/time components
Type: enhancement Stage: needs patch
Components: Extension Modules Versions: Python 3.5
process
Status: open Resolution:
Dependencies: 17884 Superseder:
Assigned To: Nosy List: belopolsky, mark.dickinson
Priority: low Keywords:

Created on 2010-06-20 01:44 by belopolsky, last changed 2022-04-11 14:57 by admin.

Messages (2)
msg108222 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-06-20 01:44
"""
As an aside, I dislike the fact that the datetime module uses a C 'int' for date ordinals, and clearly assumes that it'll be at least 32 bits.  int could be as small as 16 bits on some systems (small embedded systems?).  But that's another issue.
""" -- Mark Dickinson 

A comment and an assertion at the top of the module suggest that this was deliberate.

/* We require that C int be at least 32 bits, and use int virtually                                                                                  
 * everywhere.  In just a few cases we use a temp long, where a Python                                                                               
 * API returns a C long.  In such cases, we have to ensure that the                                                                                  
 * final result fits in a C int (this can be an issue on 64-bit boxes).                                                                              
 */
#if SIZEOF_INT < 4
#       error "datetime.c requires that C int have at least 32 bits"
#endif

However, since ranges of all integers are well defined in this module, there is little to be gained from the uncertainty about sizes of int and long. (For example, the allowed range of dates will not magically increase on a platform with 64 bit ints.)

I propose using explicitly sized C99 types int32_t and int64_t or rather their blessed for use in python equivalents PY_INTXX_T) throughout the module.
msg229447 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2014-10-15 13:46
See also #17884.
History
Date User Action Args
2022-04-11 14:57:02adminsetgithub: 53280
2014-10-15 13:46:18belopolskysetdependencies: + Try to reuse stdint.h types like int32_t
messages: + msg229447
2014-06-29 23:33:35belopolskysetassignee: belopolsky ->
2014-06-17 21:01:05BreamoreBoysetversions: + Python 3.5, - Python 3.3
2011-01-11 01:57:40belopolskysetversions: + Python 3.3, - Python 3.2
2010-06-20 01:44:15belopolskycreate