Tip: List vs. Set in Python

In Python, if you have a “list” with a lot of members and you need to do many membership checks, it will be better to use a “set” instead, because the checks are linear for lists and constant for sets.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.