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 cProfile | |
import pstats | |
def measure(func): | |
""" The decorator. """ | |
def profiling(*args, **kwargs): | |
""" The profiler. """ | |
prof = cProfile.Profile() | |
prof.enable() |
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
from functools import partial | |
curry = lambda f, g: partial( | |
lambda F, G, *args, **kwargs: F(G(*args,**kwargs)), | |
f, g | |
) |
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
lambda filters: "&".join(map(lambda kv: '%s=%s' % kv, filters.iteritems())) |
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
# Get the intersected dict from x and y | |
lambda x,y: {i:x[i] for i in set(x.keys()) & set(y.keys())} | |
# Get from x only the keys in list y, assuming y is a list, tuple or set.. | |
lambda x,y: {i:x[i] for i in set(x.keys()) & set(y)} |
NewerOlder