- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
➜
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.
Created on 2017-09-25 12:11 by Anran Yang, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Messages (2) | ||
|---|---|---|
| msg302950 - (view) | Author: Anran Yang (Anran Yang) | Date: 2017-09-25 12:11 |
At the end of the Functional Programming HOWTO document (https://docs.python.org/3.7/howto/functional.html) the usage of reduce/lambda/for loops are compared and discussed. However, the example for reduce seems sub-optimal and thus the discussion is not that efficient. The example: total = functools.reduce(lambda a, b: (0, a[1] + b[1]), items)[1] could be changed to: total = functools.reduce(lambda total, item: total + item[1], items, 0) which is much more readable and is actually not much inferior to the loop one (though the sum approach is still more concise). |
||
| msg303015 - (view) | Author: Raymond Hettinger (rhettinger) * ![]() |
Date: 2017-09-26 06:41 |
I think the existing code conveys the author's message better than the proposed revision. The example isn't about efficiency; rather, it is about comparing several alternative formulations with this one being the weakest of the lost. For emphasizing that point and not getting lost in a made-up example, the a[1] and b[1] style is more effective. That's for the suggestion but I don't think it is a win. |
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:52 | admin | set | github: 75756 |
| 2017-09-26 06:41:01 | rhettinger | set | status: open -> closed nosy: + rhettinger messages: + msg303015 resolution: rejected stage: resolved |
| 2017-09-25 12:11:35 | Anran Yang | create |
Powered by Roundup Copyright © 1990-2022, Python Software Foundation
Legal Statements

