Opened 2 years ago

Closed 2 years ago

#23590 closed defect (wontfix)

Matching comparison behavior between Integers and ints

Reported by: roed Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: python3 Keywords:
Cc: Stefan Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

The following has changed since Sage 7.2.

sage: sorted([1,2,'a'])
['a', 1, 2]
sage: sorted([1r,2r,'a'])
[1, 2, 'a']

I think that these should have the same result (matching the Python int behavior, since we can change Integer comparison more easily).

Change History (5)

comment:1 Changed 2 years ago by Stefan

  • Cc Stefan added

comment:2 Changed 2 years ago by chapoton

Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> sorted([1,2,'a'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unorderable types: str() < int()

comment:3 Changed 2 years ago by Stefan

Yes, but we aren't on Python 3 yet, so it's still changed behavior compared to the past for the current version of Sage.

comment:4 Changed 2 years ago by tscrim

I'm mostly with Frédéric on this one. I don't think it is worth spending time worrying about how int and Integer compare with strings (well...hopefully Integer will be consistent with int when we go to Python3). Actually, I believe it is random for int and str as it is based on memory location, but I could be wrong (at least I cannot get a test to (dis)prove it).

comment:5 Changed 2 years ago by jdemeyer

  • Milestone changed from sage-8.1 to sage-duplicate/invalid/wontfix
  • Resolution set to wontfix
  • Status changed from new to closed

+1, this comparison is pointless anyway.

Note: See TracTickets for help on using tickets.