[Sage vs Python] Matrix indexing and list standards
Hello, Sage Community!
Since I learned Sage, I have used the notation A[i][j]
(which obviously came from my previous experience with Python lists) to access the (i+1, j+1)-th element of a matrix. However, I discovered a few weeks ago that I can also use the syntax A[i,j]
. I am wondering which of these two ways of matrix indexing is preferred in Sage?
My tests using timeit
indicate that the second syntax is faster than the first one by a factor of 500. So I suppose it to be simply natural that the fastest syntax is preferred. However, why to deviate from the list syntax? After all, lists and lists of lists are (in some sense) arrays, too.
On the other hand, talking about lists, there is the syntax [1..10]
, which creates the list
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Why is this the case when Python would ignore the 10? For example, range(1, 10)
is equivalent to
[1, 2, 3, 4, 5, 6, 7, 8, 9]
Even srange(1, 10)
creates the same list, but with Sage Integer
s, instead of Python's int
s. Is there any good reason for having [1..10]
be equivalent to srange(1, 11)
?
Thanks in advance for your answers!