On my IPython machine
In [1]: foo = True
In [2]: bar = False
In [3]: baz = True
In [4]: %%timeit
...: if foo and not bar and baz:
...: lambda: None
1000000 loops, best of 3: 265 ns per loop
In [5]: %%timeit
...: if foo:
...: if not bar:
...: if baz:
...: lambda: None
1000000 loops, best of 3: 275 ns per loop
It seems like overhead is 10ns if you split them. If 10ns matters, you should probably use a different language.
So, for all practical purposes, no, there is no difference.
If we look a little deeper, we will see where this tiny difference comes from.
In [6]: def compound():
...: if foo and not bar and baz:
...: lambda: None
In [7]: def multiple():
....: if foo:
....: if not bar:
....: if baz:
....: lambda: None
In [8]: import dis
In [9]: dis.dis(compound)
2 0 LOAD_GLOBAL 0 (foo)
3 POP_JUMP_IF_FALSE 29
6 LOAD_GLOBAL 1 (bar)
9 UNARY_NOT
10 POP_JUMP_IF_FALSE 29
13 LOAD_GLOBAL 2 (baz)
16 POP_JUMP_IF_FALSE 29
3 19 LOAD_CONST 1 (<code object <lambda> at 0x101d953b0, file "<ipython-input-9-d057c552d038>", line 3>)
22 MAKE_FUNCTION 0
25 POP_TOP
26 JUMP_FORWARD 0 (to 29)
>> 29 LOAD_CONST 0 (None)
32 RETURN_VALUE
It has 13 instructions
In [15]: dis.dis(g)
2 0 LOAD_GLOBAL 0 (foo)
3 POP_JUMP_IF_FALSE 34
3 6 LOAD_GLOBAL 1 (bar)
9 POP_JUMP_IF_TRUE 34
4 12 LOAD_GLOBAL 2 (baz)
15 POP_JUMP_IF_FALSE 31
5 18 LOAD_CONST 1 (<code object <lambda> at 0x101dbb530, file "<ipython-input-10-32b41e5f6f2b>", line 5>)
21 MAKE_FUNCTION 0
24 POP_TOP
25 JUMP_ABSOLUTE 31
28 JUMP_ABSOLUTE 34
>> 31 JUMP_FORWARD 0 (to 34)
>> 34 LOAD_CONST 0 (None)
37 RETURN_VALUE
It has 14 instructions.
IPython , 2.7.5, , , Python, , , .