[issue30302] Improve .__repr__ implementation for datetime.timedelta

STINNER Victor report at bugs.python.org
Fri Jun 30 16:59:31 EDT 2017


STINNER Victor added the comment:

Serhiy: "The C code looks cumbersome. It could be made a little simpler if accumulate arguments into a string rather than a list."

Utkarsh's first version used C code. I proposed to use a PyList and PyUnicodeObject strings to not have to compute the size of the char[] buffers.

The annoying part is to handle the ", " separator. I also had bad experiences with handling char* strings. It's so easy to make mistakes :-(

IMHO the current C code using Python objects is not that complex, but I don't really care of the implementation as soon as it works :-)

----------

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


More information about the Python-bugs-list mailing list