This file contains 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 types | |
ARGS_FLAG = 4 | |
KWARGS_FLAG = 8 | |
def valid(f, args, kwargs): | |
def dummy(): | |
pass |
This file contains 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 gc | |
import sys | |
def giveupthefunc(): | |
code = sys._getframe(1).f_code | |
functype = type(lambda: 0) | |
for func in gc.get_referrers(code): | |
if type(func) is functype and getattr(func, "func_code", None) is code: | |
return func |
This file contains 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 itertools | |
def pyfunc_fastest(x): | |
t = [] | |
lenList = len(x) | |
extend = t.extend | |
for l in xrange(0, lenList): | |
extend([x[l]] * (lenList - l)) | |
def pyfunc_iadd(x): |
This file contains 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
def with_intern(): | |
def a(): | |
return 'foo' | |
def b(): | |
return 'foo' | |
return a() is b() | |
print(with_intern()) # True | |
def with_no_intern(): |
This file contains 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 itertools | |
test_strings = {} | |
def make_harness(args, base_setup, default_run="{0}", default_setup=''): | |
""" Creates a decorator to create command strings for timeit.Timer """ | |
def test(run=default_run, setup=default_setup): | |
def dec(f): | |
name = f.__name__ |