Last active
December 12, 2015 01:19
-
-
Save spoof/4690505 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| spoof@spoofs-mac:tests% python test_filter.py | |
| list comprehension 0.0898420810699 | |
| filter lambda 0.104062080383 | |
| filter None 2.14576721191e-06 | |
| -------------------- | |
| def list_comprehension(data): | |
| return [x for x in data if x] | |
| 17 0 BUILD_LIST 0 | |
| 3 LOAD_FAST 0 (data) | |
| 6 GET_ITER | |
| >> 7 FOR_ITER 18 (to 28) | |
| 10 STORE_FAST 1 (x) | |
| 13 LOAD_FAST 1 (x) | |
| 16 POP_JUMP_IF_FALSE 7 | |
| 19 LOAD_FAST 1 (x) | |
| 22 LIST_APPEND 2 | |
| 25 JUMP_ABSOLUTE 7 | |
| >> 28 RETURN_VALUE | |
| None | |
| -------------------- | |
| def lambda_filter(data): | |
| _f = lambda x: x | |
| return filter(_f, data) | |
| 21 0 LOAD_CONST 1 (<code object <lambda> at 0x104c29d30, file "test_filter.py", line 21>) | |
| 3 MAKE_FUNCTION 0 | |
| 6 STORE_FAST 1 (_f) | |
| 22 9 LOAD_GLOBAL 0 (filter) | |
| 12 LOAD_FAST 1 (_f) | |
| 15 LOAD_FAST 0 (data) | |
| 18 CALL_FUNCTION 2 | |
| 21 RETURN_VALUE | |
| None | |
| -------------------- | |
| def lambda_none_filter(data): | |
| return filter(None, data) | |
| 26 0 LOAD_GLOBAL 0 (filter) | |
| 3 LOAD_CONST 0 (None) | |
| 6 LOAD_FAST 0 (data) | |
| 9 CALL_FUNCTION 2 | |
| 12 RETURN_VALUE | |
| None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment