Tuple or list when using 'in' in an 'if' clause?
Which approach is better? Using a tuple, like: if number in (1, 2): or a list, like: if number in [1, 2]: Which one is recommended for such uses and why (both logical and performance wise)? The CPython interpreter replaces the second form with the first . That's because loading the tuple from a constant is one operation, but the list would be 3 operations; load the two integer contents and build a new list object. Because you are using a list literal that isn't otherwise reachable, it is substituted for a tuple: >>> import dis >>> dis.dis(compile('number in [1, 2]', '<stdin>', 'eval')) 1 0