[Datetime-SIG] PEP-0500 (Alternative datetime arithmetic) Was: PEP 495 ... is ready ...

Alexander Belopolsky alexander.belopolsky at gmail.com
Wed Aug 19 02:30:14 CEST 2015

On Tue, Aug 18, 2015 at 8:00 PM, Ethan Furman <ethan at stoneleaf.us> wrote:

> On 08/18/2015 04:42 PM, Alexander Belopolsky wrote:
> [...] and __datetime_diff__ / __datetime_sub__ may be [...]
> Why are there separate methods for subtracting a timedelta vs a datetime?
> Seems like one method is sufficient.

The dispatch based on the type of "other" is already implemented in the
datetime, so there is no need to reimplement it in each tzinfo
implementation.  It is expected that most implementations that override
__datetime_add__ will provide __datetime_sub__ which is just
__datetime_add__(dt, -delta) or a copy of __datetime_add__ with a few +'s
replaced with -'s, so implementing __datetime_sub__  won't be much of an
extra burden.

Also, while it is not in the PEP yet, I plan to add a C-API specification
in which C slots corresponding to __datetime_diff__ and __datetime_sub__
will have different signatures.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150818/ac68694e/attachment.html>

More information about the Datetime-SIG mailing list