Opened 8 years ago

Closed 6 years ago

#16457 closed enhancement (fixed)

Rename xrange() to range()

Reported by: aapitzsch Owned by:
Priority: major Milestone: sage-7.5
Component: python3 Keywords: python3
Cc: jdemeyer, tscrim, aapitzsch, embray Merged in:
Authors: André Apitzsch, Frédéric Chapoton Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: dd549fa (Commits, GitHub, GitLab) Commit: dd549fa80f073333fb53fe8d0634eb19281475e6
Dependencies: Stopgaps:

Status badges

Description (last modified by chapoton)

In python3 xrange() was renamed to range().

With this patch iterators will become lists till we switch to python 3. But this should be okay for small intervals. (That's the reason for not changing all.)

This is part of #16081.

NOTE: xrange can (and should) stay inside the code of .pyx files

Change History (18)

comment:1 Changed 8 years ago by aapitzsch

  • Authors set to André Apitzsch
  • Branch set to u/aapitzsch/ticket/16457
  • Commit set to d3bae80fba004f3a633c3e0759293a61854f0208
  • Keywords python3 added
  • Status changed from new to needs_review

New commits:

d3bae80rename xrange() to range()

comment:2 Changed 8 years ago by vdelecroix

I am strongly against that this ticket is being merge now. We are far from having the Python 3 switch tomorrow (is it even a blocker for sage-6.3?). It will slow down everything. xrange is faster by 40% on lists of size 100:

sage: timeit("for i in xrange(100):\n for j in xrange(100): pass")
625 loops, best of 3: 362 µs per loop
sage: timeit("for i in range(100):\n for j in range(100): pass")
625 loops, best of 3: 501 µs per loop

And there are many of them in Sage source code.

comment:3 Changed 8 years ago by kcrisman

Yeah, this does seem somewhat premature due to this. However, it's still good to have a trial version here, especially if someone decided to make a 'Sage-py3' branch for testing at some point.

comment:4 Changed 8 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:5 Changed 8 years ago by jdemeyer

  • Milestone changed from sage-6.4 to sage-pending

comment:6 Changed 8 years ago by jdemeyer

  • Status changed from needs_review to needs_work

comment:7 Changed 6 years ago by chapoton

  • Component changed from misc to python3

comment:8 Changed 6 years ago by chapoton

see #21375 for a step in this direction

comment:9 Changed 6 years ago by chapoton

  • Milestone changed from sage-pending to sage-7.4

comment:10 Changed 6 years ago by chapoton

  • Description modified (diff)

NOTE: xrange can (and should) stay inside the code of .pyx files

comment:11 Changed 6 years ago by chapoton

see #21478, #21530, #21531, #21548 for some further steps

comment:12 Changed 6 years ago by chapoton

after #21763, #21751, #21677 we will be almost done

comment:13 Changed 6 years ago by chapoton

  • Branch u/aapitzsch/ticket/16457 deleted
  • Commit d3bae80fba004f3a633c3e0759293a61854f0208 deleted

This is now essentially done. There remains only very few xrange in the code. Let us get rid of them here if possible.

comment:14 Changed 6 years ago by chapoton

  • Branch set to u/chapoton/16457
  • Cc jdemeyer tscrim aapitzsch embray added
  • Commit set to dd549fa80f073333fb53fe8d0634eb19281475e6
  • Milestone changed from sage-7.4 to sage-7.5
  • Status changed from needs_work to needs_review

ok, here is a simple branch eliminating essentially all the remaining instances of xrange, mostly in the doc.

There will remain to handle ticket #16081.


New commits:

dd549fatrac 16457 eliminate last traces of xrange

comment:15 Changed 6 years ago by chapoton

at least one bot is green, please review

comment:16 Changed 6 years ago by chapoton

*ping* ?

comment:17 Changed 6 years ago by tscrim

  • Authors changed from André Apitzsch to André Apitzsch, Frédéric Chapoton
  • Reviewers set to Travis Scrimshaw
  • Status changed from needs_review to positive_review

comment:18 Changed 6 years ago by vbraun

  • Branch changed from u/chapoton/16457 to dd549fa80f073333fb53fe8d0634eb19281475e6
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.