Open slel opened 4 years ago
Initial list from a look at:
sage: [x for x in dir() if 'range' in x]
Description changed:
---
+++
@@ -3,6 +3,12 @@
Python 3 only has `range` which behaves like the old `xrange`.
This ticket is to rename or change our range-like functions accordingly.
+
+To go further we could make sure they all follow similar semantics, i.e.:
+- `f(a)` for the range from `0` included to `a` excluded
+- `f(a, b)` for the range from `a` included to `b` excluded
+- `f(a, b, c)` for the range from `a` included to `b` excluded, by steps of `c`
+
Functions in the global name space:
- `ellipsis_range`
Description changed:
---
+++
@@ -26,5 +26,7 @@
See also:
+- #29760: `prime_range` should allow a step
+- #29728: Meta-ticket: improve compatibility with the Python library
- #18298: `prime_range` vs `primes`
-- #29728: Meta-ticket: improve compatibility with the Python library
+
Description changed:
---
+++
@@ -28,5 +28,7 @@
- #29760: `prime_range` should allow a step
- #29728: Meta-ticket: improve compatibility with the Python library
+- #24543: py3: need to fix sequence of ranges
- #18298: `prime_range` vs `primes`
+- #17373: Add more examples for when `srange` is better than `range`
Setting new milestone based on a cursory review of ticket status, priority, and last modification date.
Branch: public/srange_as_iterator
Branch pushed to git repo; I updated commit sha1. New commits:
efc3d67 | make srange an iterator |
Commit: efc3d67
Making srange an iterator almost break every single file. Any volunteer to handle the fixes ?
Branch pushed to git repo; I updated commit sha1. New commits:
3653098 | one fix in plot |
Branch pushed to git repo; I updated commit sha1. New commits:
02df950 | one more fix |
Branch pushed to git repo; I updated commit sha1. New commits:
9eb53f6 | more fixes for srange |
We meet the following issue:
sage: A = srange(1,4)
sage: list(A)
[1, 2, 3]
sage: list(A)
[]
sage: B = range(1,4)
sage: list(B)
[1, 2, 3]
sage: list(B)
[1, 2, 3]
According to the Python 3 documentation for range:
Rather than being a function, range is actually an immutable sequence type, as documented in Ranges and Sequence Types — list, tuple, range.
Could we make srange
an immutable sequence type too?
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
9e33b25 | make srange an iterator |
Branch pushed to git repo; I updated commit sha1. New commits:
b8740a6 | using Iterable from collections.abc |
Branch pushed to git repo; I updated commit sha1. New commits:
6025e4d | one more fix for srange |
Branch pushed to git repo; I updated commit sha1. New commits:
acd32da | one more fix |
I agree with comment:14 - this is problematic. srange
should really construct an object similar to range objects in python3
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
4910cc6 | make srange an iterator |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
3cee22e | make srange an iterator |
Can we just get rid of all *mrange*
and replace its uses by itertools.product
?
(I've opened #34337 for this.)
Description changed:
---
+++
@@ -31,4 +31,4 @@
- #24543: py3: need to fix sequence of ranges
- #18298: `prime_range` vs `primes`
- #17373: Add more examples for when `srange` is better than `range`
-
+- #34337: Deprecate `sage.misc.mrange.*mrange*` and `cartesian_product_iterator`
Replying to @mkoeppe:
Can we just get rid of all
*mrange*
and replace its uses byitertools.product
? (I've opened #34337 for this.)
I posted something on #34337 about somet hings to be careful about with doing the replacement.
I would suggest to add #31544 to the list of related issues.
Python 2 had
range
(returning lists) andxrange
(returning iterators).Python 3 only has
range
which behaves like the oldxrange
.This ticket is to rename or change our range-like functions accordingly.
To go further we could make sure they all follow similar semantics, i.e.:
f(a)
for the range from0
included toa
excludedf(a, b)
for the range froma
included tob
excludedf(a, b, c)
for the range froma
included tob
excluded, by steps ofc
Functions in the global name space:
ellipsis_range
fibonacci_xrange
mrange
mrange_iter
prime_range
randrange
range
srange
sxrange
xmrange
xmrange_iter
xsrange
See also:
29760:
prime_range
should allow a step29728: Meta-ticket: improve compatibility with the Python library
24543: py3: need to fix sequence of ranges
18298:
prime_range
vsprimes
17373: Add more examples for when
srange
is better thanrange
34337: Deprecate
sage.misc.mrange.*mrange*
andcartesian_product_iterator
CC: @slel @tscrim @fchapoton
Component: python3
Keywords: range
Branch/Commit: public/srange_as_iterator @
3cee22e
Issue created by migration from https://trac.sagemath.org/ticket/30121