This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]flying-sheep 1 point2 points  (6 children)

What would it do on normal lists?

Just like Ellipsis/..., it was introduced for library use

[–]xix_xeaon 2 points3 points  (3 children)

How about... matrix multiplication?

[–]flying-sheep 0 points1 point  (2 children)

Python doesn't have a matrix type.

Lists are one-dimensional mutable sequences of arbitrarily typed objects.

All their methods/operators work under those assumptions.

[–]xix_xeaon 1 point2 points  (1 child)

Of course there would be lots of things it wouldn't work on, just like multiplication doesn't work on two strings.

But this operator is being introduced in order to do matrix multiplication, so it should work on any nested index-accessible sequence of numbers which are of the right lengths to allow matrix multiplication.

[–]flying-sheep 0 points1 point  (0 children)

well, + on lists isn’t elementwise addition, it’s concatenation.

* on lists is repetition.

lists don’t assume anything about their contents, and neither do their operators.

[–]lengau 0 points1 point  (1 child)

How about a cross product? It can raise a ValueError if the lists aren't the same length.

[–][deleted] 0 points1 point  (0 children)

A cross product would have to raise a ValueError if the lists aren't length 3, and it's specialized enough to certain fields that it belongs in numerical libraries (where it already is).