Skip to content

Remove the test for xc in _pydecimal#27102

Merged
ambv merged 1 commit intopython:mainfrom
donno2048:patch-1
Jul 15, 2021
Merged

Remove the test for xc in _pydecimal#27102
ambv merged 1 commit intopython:mainfrom
donno2048:patch-1

Conversation

@donno2048
Copy link
Copy Markdown
Contributor

No description provided.

If `xc == 1` then it'll return in line `2140`
@ambv
Copy link
Copy Markdown
Contributor

ambv commented Jul 13, 2021

How is it obvious that xc is never 1?

@donno2048
Copy link
Copy Markdown
Contributor Author

If xc == 1 then the function will return in line 2140

@donno2048 donno2048 changed the title Remove unnecessary conditions Remove the test for xc in _pydecimal Jul 13, 2021
@donno2048
Copy link
Copy Markdown
Contributor Author

@ambv any response?

@ambv
Copy link
Copy Markdown
Contributor

ambv commented Jul 15, 2021

Sorry, it's still unclear to me that this is certain. On lines 2190, 2200, and 2217 there might be cases in which xc becomes 1. Since the code is very math-heavy there, I don't feel confident about dropping those checks.

@ambv ambv closed this Jul 15, 2021
@donno2048
Copy link
Copy Markdown
Contributor Author

Sorry, it's still unclear to me that this is certain. On lines 2190, 2200, and 2217 there might be cases in which xc becomes 1. Since the code is very math-heavy there, I don't feel confident about dropping those checks.

But everyone of this lines is inside the y.sign == 1 condition which means they'll return in line 2224 (or before) and won't get to this part any way.

@donno2048
Copy link
Copy Markdown
Contributor Author

@ambv

@ambv
Copy link
Copy Markdown
Contributor

ambv commented Jul 15, 2021

Do you have a tool with which you found the issue in this pull request and your other pull requests? Or did you do this manually?

For me, there's too many paths through this function for us to be able to reliably tell.

@donno2048
Copy link
Copy Markdown
Contributor Author

Found it by hand, any code analysis tool will give probably thousands of errors and warning, I won't go through it all

@donno2048
Copy link
Copy Markdown
Contributor Author

For me, there's too many paths through this function for us to be able to reliably tell.

It's obviously either going to get into the condition or not, if not then xc won't change and we don't need to check for it since we know it wasn't 1 if it does enters the condition then it'll return before reaching this part in the code and we can surely just not check for xc

@ambv ambv merged commit 3527569 into python:main Jul 15, 2021
@ambv
Copy link
Copy Markdown
Contributor

ambv commented Jul 15, 2021

Thanks! ✨ 🍰 ✨

@donno2048 donno2048 deleted the patch-1 branch July 15, 2021 11:08
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.

4 participants