Last active
November 16, 2015 19:27
-
-
Save njamaleddine/0a90732d93c548f61665 to your computer and use it in GitHub Desktop.
In is optimized from using timeit to test
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
| from __future__ import print_function | |
| from timeit import timeit | |
| layout_type = 'text_only' | |
| def in_test(): | |
| text_required_layout_choice = ( | |
| 'image_and_text', 'text_over_image', 'text_only' | |
| ) | |
| if layout_type in text_required_layout_choice: | |
| return True | |
| def or_test(): | |
| if ( | |
| layout_type == 'image_and_text' or | |
| layout_type == 'text_over_image' or | |
| layout_type == 'text_only' | |
| ): | |
| return True | |
| print("Testing `in`: {}".format(timeit('in_test()', 'from __main__ import in_test'))) | |
| print("Testing `or`: {}".format(timeit('or_test()', 'from __main__ import or_test'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment