Skip to content

Instantly share code, notes, and snippets.

@sigmaris
Created January 21, 2015 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sigmaris/561ec0df4686cf756940 to your computer and use it in GitHub Desktop.
Save sigmaris/561ec0df4686cf756940 to your computer and use it in GitHub Desktop.
>>> def f1(y):
... return set(x for x in y)
...
>>> def f2(y):
... return {x for x in y}
...
>>> dis.dis(f1)
2 0 LOAD_GLOBAL 0 (set)
3 LOAD_CONST 1 (<code object <genexpr> at 0x10abecd30, file "<stdin>", line 2>)
6 MAKE_FUNCTION 0
9 LOAD_FAST 0 (y)
12 GET_ITER
13 CALL_FUNCTION 1
16 CALL_FUNCTION 1
19 RETURN_VALUE
>>> dis.dis(f2)
2 0 LOAD_CONST 1 (<code object <setcomp> at 0x10ac14130, file "<stdin>", line 2>)
3 MAKE_FUNCTION 0
6 LOAD_FAST 0 (y)
9 GET_ITER
10 CALL_FUNCTION 1
13 RETURN_VALUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment