[Python-Dev] PEP 495 Was: PEP 498: Literal String Interpolation is ready for pronouncement

Terry Reedy tjreedy at udel.edu
Sun Sep 13 02:49:12 CEST 2015


On 9/12/2015 1:04 PM, Alexander Belopolsky wrote:
>
>
> On Sat, Sep 12, 2015 at 1:20 AM, Terry Reedy <tjreedy at udel.edu
> <mailto:tjreedy at udel.edu>> wrote:
>
>       A mathematician has no problem with 'a'+'b' != 'b'+'a'.
>
> I doubt it.  A binary operation denoted + (and called addition) is
> almost universally a commutative operation.  A non-commutative binary
> operation is usually denoted * (and called multiplication).

I am aware of the single-operation group theory convention, but the 
context was sequence concatenation and scalar multiplication, where '*' 
is repeated '+'.  But these details are not directly relevant to DateTimes.

>        After closure,

I perhaps should have said 'completeness'.  In any case, I was referring 
to 'a op b' existing for all a and b in the set.

> Agree, and we have a solution for PEP 495 which preserves == as and
> equivalence (symmetric, reflexive and transitive) relationship.
>
>     Datetime members, are rather unusual beasts. They are triples
>     consisting of a member of a discrete sequence (with some odd gaps),

Your correction, summarized, is that there are no gaps, so the set is 
simpler than I thought. Skipping on to the heart of the matter.

> I am not concerned about '-'.  My main concern is about order
> operations.

Is not '<' defined, in the obvious way, in terms of '-' and the sign of 
the resul?

>  I am happy with the solution I have for ==, but I am still
> struggling with the non-transitivity of <.

I am guessing that the 'struggle' is at least partly this: "Is 
non-transitivity of < necessary given other constraints, including 
back-compatibility, or is there another solution possible that would 
also be <-transitive?"

> Comparison operations are special because they are used implicitly in
> other operations.  The < operator is used implicitly in bisect.  If it
> does not satisfy the (partial?) order properties, bisect may enter an
> infinite loop.

and, if we are stuck with <-intransitivity, what do we do? If 
back-compatibility allowed, I might suggest defining 'lt' or 'less' 
rather than '__lt__' so that sort and bisect don't work with DateTimes. 
Then document that the function is not transitive.

-- 
Terry Jan Reedy



More information about the Python-Dev mailing list