Skip to content

Conversation

@serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Jun 15, 2019

Also simplify the code generator and peepholer for "if" and "while" with
constant condition.
Also optimize more cases of conditional jumps with constant condition.

https://bugs.python.org/issue1875

https://bugs.python.org/issue32477

… optimized away.

Also simplify the code generator and peepholer for "if" and "while" with
constant condition.
Also optimize more cases of conditional jumps with constant condition.
Copy link
Member

@pablogsal pablogsal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Serhiy!

I left some minor comments

@@ -0,0 +1,3 @@
A :exc:`SyntaxError` is now always raised if a code blocks that will be
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'if code blocks' or 'if a code block'

@pablogsal
Copy link
Member

It seems that this is causing some errors with trace functions

Copy link
Member

@pablogsal pablogsal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bedevere-bot
Copy link

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

}
default:
default: {
if (e->kind == Constant_kind) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be it's on case in the previous switch?

(case Constant_kind: )

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

@pablogsal
Copy link
Member

@serhiy-storchaka I think we should merge this sooner than later so it can be in the next 3.8 beta release and people can interact with it more. If you don't have time I can push to the PR to fix the failing test (https://github.com/python/cpython/blob/master/Lib/test/test_sys_settrace.py#L62) if you prefer :)

@serhiy-storchaka
Copy link
Member Author

No, this PR is not ready yet.

* constant = 1: "if 1", "if 2", ...
* constant = -1: rest */
if (constant == 0) {
BEGIN_DO_NOT_EMIT_BYTECODE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this macro and the attribute in the compiler struct if is not used anymore

@markshannon
Copy link
Member

This change was implemented as part of PEP 626, so this PR is now obsolete.

@markshannon markshannon closed this Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants