Issue 13727: Accessor macros for PyDateTime_Delta members (original) (raw)

Issue13727

Created on 2012-01-07 13:50 by amaury.forgeotdarc, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
timedelta_macros.patch amaury.forgeotdarc,2012-01-07 13:50
Messages (5)
msg150796 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2012-01-07 13:50
All objects of the datetime module have macros to access their properties, except timedelta. This simple patch adds the macros PyDateTime_DELTA_GET_DAYS, PyDateTime_DELTA_GET_SECONDS, PyDateTime_DELTA_GET_MICROSECONDS; module developers are encouraged to use these instead of obj->seconds for example. Motivation: PyPy cannot easily expose PyDateTime_Delta fields because datetime is implemented as a pure Python module and it's difficult to rebuild a C structure from a heap type. In PyPy these macros are actually functions, which do something similar to PyLong_AsLong(PyObject_GetAttrString(obj, "seconds")): https://bitbucket.org/pypy/pypy/src/b67e65d709e1/pypy/module/cpyext/cdatetime.py#cl-235
msg151410 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-01-16 21:40
The macros should be named PyDelta_XXX, as PyDelta_Check and friend. Otherwise, makes sense.
msg151411 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2012-01-16 21:43
I named them following the other accessor macros: PyDateTime_TIME_GET_HOUR(), even though the check function is named PyTime_Check(). Which inconsistency do you prefer? :)
msg151412 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-01-16 21:51
Ow. Then I don't mind :)
msg151486 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-01-17 20:39
New changeset 463acb73fd79 by Amaury Forgeot d'Arc in branch 'default': Issue #13727: Add 3 macros to access PyDateTime_Delta members: http://hg.python.org/cpython/rev/463acb73fd79
History
Date User Action Args
2022-04-11 14:57:25 admin set github: 57936
2012-01-17 20:40:18 amaury.forgeotdarc set status: open -> closedresolution: fixed
2012-01-17 20:39:44 python-dev set nosy: + python-devmessages: +
2012-01-16 21:51:39 pitrou set messages: +
2012-01-16 21:43:32 amaury.forgeotdarc set messages: +
2012-01-16 21:40:45 pitrou set nosy: + pitroumessages: +
2012-01-07 13:50:35 amaury.forgeotdarc create