-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: refactor sentiment analyzer by removing dead and slow perfomance code #2804
Conversation
I suppose that
See this SO for more information. With Generally, the use of >>> a = 2000
>>> b = 2000
>>> a == b
True
>>> a is b
False It can also cause some really confusing bugs: >>> a = 2000
>>> b = 2000
>>> a is b
False
>>> c = 200
>>> d = 200
>>> c is d
True (more information on this "bug") In conclusion: Yes: if greeting:
No: if greeting == True:
Worse: if greeting is True: So, in short, I'm in favor of this PR, with the exception of the following: |
I like this, using |
Co-authored-by: Tom Aarsen <37621491+tomaarsen@users.noreply.github.com>
I did add the suggested changes. |
@12mohaned Thank you for your changes! I can always respect a code quality PR. |
The pull request refactors the sentiment analyser class by generally doing the following points:
A single if statement or even dozens won not be that bad, but hundred of if's statement, this may cause some minor performance issues. The below numbers illustrates better.
python -m timeit -s "variable=False" "if variable == True: pass"
output:
python -m timeit -s "variable=True" "if variable is True: pass"
python -m timeit -s "variable=True" "if variable: pass"
I believe this may affect the performance of the sentiment analyser in a minor way.