tonybaloney / perflint

Python Linter for performance anti patterns
MIT License
660 stars 9 forks source link

Too many false positives #17

Open ArneBachmannDLR opened 2 years ago

ArneBachmannDLR commented 2 years ago

Great project! I found at least one line of code that could be improved (moved loop to a dictionary expression); but I see, however, 99.5% false positives, e.g.:

adamzev commented 2 years ago

I enjoyed the talk and checking out the tool!

I ran into some issues with Pandas treating lists differently than tuples (when using them as keys).

I also hit a lot of false positives with loop-invariant-statements (unless I'm missing something).

I tried to simplify out an example of something it'd hit a false positive on:

keys = []
for record in ({'a': 4}, {'b': 8}):
    keys.append(tuple(k for k in record if k in ('b', 'c')))

print(keys)

I think it was saying k in ('b', 'c') was loop invariant.