[issue24416] Return a namedtuple from date.isocalendar()

Paul Ganssle report at bugs.python.org
Sun Sep 1 12:12:33 EDT 2019


Paul Ganssle <p.ganssle at gmail.com> added the comment:

> But I'm wondering how the `fromisocalendar` API relates to this patch.
> Rather, wouldn't this patch contribute to improving the usability of the `fromisocalendar` API?

The `fromisocalendar` API relates to this patch only insofar as it is the inverse function of `isocalendar` and in some sense it allows specifying the parameters by keyword rather by position. I was merely bringing up that we didn't choose that API because we thought people would or should want or need to specify the individual components by keyword but because we didn't have an easy way to maintain the same API in the pure Python and C APIs at the time. By contrast, returning a plain tuple from `isocalendar()` is the easier *and* more performant thing to do, and given that any benefits seem marginal I'm against the switch.

I think that the usability of `fromisoformat` with the output of `isocalendar` will be largely unchanged if we were to switch to returning a namedtuple.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue24416>
_______________________________________


More information about the Python-bugs-list mailing list