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
| import sys | |
| from operator import gt, ge | |
| cmp = ge | |
| def search(a, x): | |
| print('search:', x) | |
| i, j = 0, len(a) | |
| while i < j: | |
| h = (i+j) // 2 |
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 timeit import Timer | |
| cases = list(ln.split('#') for ln in | |
| """array('i', [0]) * n #arr * n | |
| array('i', [0]*n) #arr(lst*n) | |
| array('i', range(n)) #arr(range) | |
| array('i', (0 for _ in range(n))) #arr(0 for range) | |
| """.splitlines()) | |
| for i in range(8): |
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
| import timeit | |
| import random | |
| import array | |
| setups = """xs = array('i', [0]) * n #array | |
| xs = [0] * n #list | |
| """ | |
| # xs = [None] * n #list | |
| # ^^^^ make no difference in timing |
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
| find -name '*.rs' -exec bash -c \ | |
| 'wc -c $0; base64 -w0 < $0 | wc -c; ruby -r uri -e "p URI.encode_www_form_component(STDIN.read).size" < $0; echo' {} \; |
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
| run: pt | |
| ./pt | |
| pt: printime.c | |
| cc `python3-config --cflags` -o $@ $^ `python3-config --ldflags --embed` | |
| clear: | |
| rm -f pt |
OlderNewer