Skip to content
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

use-tuple-over-list already exists in pylint in the "code style" extensions as consider-using-tuple #23

Open
Pierre-Sassoulas opened this issue Apr 1, 2022 · 3 comments

Comments

@Pierre-Sassoulas
Copy link

Pierre-Sassoulas commented Apr 1, 2022

https://pylint.pycqa.org/en/latest/messages/refactor/consider-using-tuple.html

There was a discussion about the performance benefits and we concluded that it's a style check and not a performance check. Feel free to chime in :)

For reference I'm trying to integrate the check in pylint here: pylint-dev/pylint#6078

@tonybaloney
Copy link
Owner

Thanks! I wonder why it didn't flag that on my test cases then. I'll have another look

@Pierre-Sassoulas
Copy link
Author

It might be because this needs to be activated explicitly (it's an extension). The conversation is long but should clear up the reasoning behind the use-set-for-membership message that was added alongside it.

@woctezuma
Copy link

woctezuma commented Oct 28, 2022

Maybe the README should be updated.

In the README of perflint:

Constructing a tuple is faster than a list and indexing tuples is faster.
When the sequence is not mutated, then a tuple should be used instead.

vs. on the website of pylint:

Only for style consistency! Emitted where an in-place defined list can be replaced by a tuple.
Due to optimizations by CPython, there is no performance benefit from it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants