On Tue, Aug 18, 2015 at 8:00 PM, Ethan Furman <[email protected]> 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.
_______________________________________________ Datetime-SIG mailing list [email protected] https://mail.python.org/mailman/listinfo/datetime-sig The PSF Code of Conduct applies to this mailing list: https://www.python.org/psf/codeofconduct/
