[issue13727] Accessor macros for PyDateTime_Delta members

Amaury Forgeot d'Arc report at bugs.python.org
Sat Jan 7 14:50:36 CET 2012


New submission from Amaury Forgeot d'Arc <amauryfa at gmail.com>:

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

----------
files: timedelta_macros.patch
keywords: patch
messages: 150796
nosy: amaury.forgeotdarc
priority: normal
severity: normal
stage: patch review
status: open
title: Accessor macros for PyDateTime_Delta members
versions: Python 3.3
Added file: http://bugs.python.org/file24160/timedelta_macros.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13727>
_______________________________________


More information about the Python-bugs-list mailing list