Opened 8 years ago
Closed 5 years ago
#15084 closed defect (duplicate)
xsrange int-overflow
Reported by: | dkrenn | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-duplicate/invalid/wontfix |
Component: | misc | Keywords: | xsrange int long overflow |
Cc: | Merged in: | ||
Authors: | Reviewers: | Jeroen Demeyer | |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
for _ in xsrange(Integer(0), Integer(2^63)): pass
gives
Traceback (click to the left of this block for traceback) ... OverflowError: Python int too large to convert to C long
(clearly, the same error raises if Integer
is skipped)
Change History (9)
comment:1 Changed 8 years ago by
- Description modified (diff)
comment:2 Changed 8 years ago by
- Description modified (diff)
comment:3 Changed 8 years ago by
comment:4 Changed 7 years ago by
- Milestone changed from sage-6.1 to sage-6.2
comment:5 Changed 7 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:6 Changed 7 years ago by
- Milestone changed from sage-6.3 to sage-6.4
comment:7 Changed 5 years ago by
- Milestone changed from sage-6.4 to sage-duplicate/invalid/wontfix
- Reviewers set to Jeroen Demeyer
- Status changed from new to needs_review
Duplicate of #20094.
comment:8 Changed 5 years ago by
- Status changed from needs_review to positive_review
comment:9 Changed 5 years ago by
- Resolution set to duplicate
- Status changed from positive_review to closed
Note: See
TracTickets for help on using
tickets.
This is a documented restriction on
xrange
and sage's code will only run into it in situations where the full iterator would never be exhausted (implementation usesxrange(icount)
). Compare:so the question is really whether
xsrange
should also be usable to create (effectively) infinite arithmetic progressions. Incidentally,xrange
andxsrange
model different kinds of objects:xrange
implements__getitem__
and__iter__
but notnext
, so it's really just modelling a finite arithmetic progression as (something close to) a list, whereasxsrange
is a generator expression, i.e., an iterator: