- 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.
| Author | serhiy.storchaka |
|---|---|
| Recipients | Mark.Shannon, Mohamed_Atef, gregory.p.smith, pablogsal, serhiy.storchaka, stestagg |
| Date | 2021-01-12.10:00:46 |
| SpamBayes Score | -1.0 |
| Marked as misclassified | Yes |
| Message-id | <1610445646.68.0.591634693473.issue42899@roundup.psfhosted.org> |
| In-reply-to |
| Content |
|---|
I am not sure that it should be fixed.
We already cut corners in similar cases and did this for years, and it always was okay. In the following example bool(a) is only called once:
if a and b:
f()
1 0 LOAD_NAME 0 (a)
2 POP_JUMP_IF_FALSE 14
4 LOAD_NAME 1 (b)
6 POP_JUMP_IF_FALSE 14
2 8 LOAD_NAME 2 (f)
10 CALL_FUNCTION 0
12 POP_TOP
>> 14 LOAD_CONST 0 (None)
16 RETURN_VALUE
It differs from the case of using temporary variable (optimization does not work here):
t = a and b
if t:
f()
1 0 LOAD_NAME 0 (a)
2 JUMP_IF_FALSE_OR_POP 6
4 LOAD_NAME 1 (b)
>> 6 STORE_NAME 2 (t)
2 8 LOAD_NAME 2 (t)
10 POP_JUMP_IF_FALSE 18
3 12 LOAD_NAME 3 (f)
14 CALL_FUNCTION 0
16 POP_TOP
>> 18 LOAD_CONST 0 (None)
20 RETURN_VALUE
(BTW, Python 3.10 produces less optimal code for that examples) |
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2021-01-12 10:00:46 | serhiy.storchaka | set | recipients: + serhiy.storchaka, gregory.p.smith, Mark.Shannon, Mohamed_Atef, pablogsal, stestagg |
| 2021-01-12 10:00:46 | serhiy.storchaka | set | messageid: <1610445646.68.0.591634693473.issue42899@roundup.psfhosted.org> |
| 2021-01-12 10:00:46 | serhiy.storchaka | link | issue42899 messages |
| 2021-01-12 10:00:46 | serhiy.storchaka | create |
Powered by Roundup Copyright © 1990-2022, Python Software Foundation
Legal Statements
