This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author email0.ya
Recipients docs@python, email0.ya, steven.daprano
Date 2020-08-19.20:09:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1597867788.25.0.0907426291326.issue41590@roundup.psfhosted.org>
In-reply-to
Content
Above is a link to part of the tutorial. An example with a for statement at the beginning is good. I am not saying that it needs to be replaced with something. The above example reads: "A list comprehension consists of brackets containing an expression followed by a for clause, then zero or more for or if clauses".
________________________________
def transpose1_3_1 (a: list) -> list:
    "" "Transpose matrix version 1.3.1" ""
    max_j = len (max (a))
    return [
        [row [j] if j <len (row)
                    else 0 for row in a]
            for j in range (max_j)]
_______________________________
Here a list comprehension consists of brackets containing an expression followed by a if clause, then else and for clause in end.
It is clear that the above is written inaccurately (i.e. it can be corrected).
I think it's a good idea to add a similar example with an if statement at the beginning.
At the end it says: “In the real world, you should prefer built-in functions to complex flow statements. The zip () function would do a great job for this use case".
It's good that this is said here about this function. I agree with the first sentence. Disagree that zip () function would do a great job for this use case (Transpose).
The examples in the tutorial only demonstrate the possibilities, they should be simple, I understand. But, they cannot be used to solve a problem with a small change in the value of variables, and this can be done very simply. The zip () function not only performed the transpose slower than even the first function, but it also cannot execute it if the argument values change slightly. She only repeated what could only work in this particular case.
It's good if the algorithms work more efficiently. It's not okay to use slow algorithms. And it would be nice if programmers, reading the tutorial, would write fast algorithms.
I already know about timeit. Thank. I have calculated the arithmetic mean for many cases. The results were stable.
I wish you good.
History
Date User Action Args
2020-08-19 20:09:48email0.yasetrecipients: + email0.ya, steven.daprano, docs@python
2020-08-19 20:09:48email0.yasetmessageid: <1597867788.25.0.0907426291326.issue41590@roundup.psfhosted.org>
2020-08-19 20:09:48email0.yalinkissue41590 messages
2020-08-19 20:09:47email0.yacreate