{"library":"perflint","title":"Perflint: Pylint Extension for Performance Anti-patterns","description":"Perflint is an extension for Pylint that identifies performance anti-patterns in Python code, helping developers optimize their applications by flagging common inefficiencies. It is currently in early beta, version 0.8.1, and may produce false positives. The project is actively maintained with a focus on enhancing code performance through static analysis.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install perflint"],"cli":null},"imports":["pylint your_module/ --load-plugins=perflint"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\n\ndef process_data(items):\n    # W8202: Global name usage in a loop\n    # os.environ is a global lookup; cache it outside the loop for performance.\n    for item in items:\n        value = os.environ.get(item, 'default') # This will trigger W8202\n        print(value)\n\ndef unnecessary_list_cast_example(data):\n    # W8101: Unnecessary use of list() on an already iterable type\n    for x in list(data): # data is already iterable, no need for list()\n        print(x)\n\ndef incorrect_dict_iterator_example(dictionary):\n    # W8102: Incorrect iterator method for dict\n    for _, value in dictionary.items(): # If only values are needed, use .values()\n        print(value)\n\nif __name__ == '__main__':\n    my_items = ['HOME', 'PATH']\n    process_data(my_items)\n    my_tuple = (1, 2, 3)\n    unnecessary_list_cast_example(my_tuple)\n    my_dict = {'a': 1, 'b': 2}\n    incorrect_dict_iterator_example(my_dict)\n","lang":"python","description":"Save the code above as `my_module.py`. Then run Perflint as a Pylint plugin. It will highlight performance anti-patterns like global lookups in loops, unnecessary list casting, and inefficient dictionary iteration.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}