passExpert Examples

A no-op placeholder; does nothing, used where syntax requires a statement

Pass bytecode: truly nothing

Verifying that pass generates no bytecode.

python
import dis

def with_pass():
    pass

def without_pass():
    return None

print("pass bytecode:")
dis.dis(with_pass)
print("\nexplicit return None:")
dis.dis(without_pass)

# pass compiles to exactly nothing — it generates
# no bytecode at all. The function still needs
# LOAD_CONST None + RETURN_VALUE for the implicit return.
print(f"\npass code size: {len(with_pass.__code__.co_code)}")
print(f"return None code size: {len(without_pass.__code__.co_code)}")

pass generates zero bytecode instructions. The only bytecode in a pass-only function is the implicit 'return None' that every function gets.

Want to try these examples interactively?

Open Expert Playground