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
class mme(object): | |
def __init__(self,f): | |
self.f = f | |
self.d = {} | |
def __call__(self,arg): | |
if arg in self.d: | |
return self.d[arg] | |
else: |
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
def accumulator(sum): | |
while True: | |
sum += yield sum | |
x = accumulator(1) | |
x.send(None) | |
x.send(5) | |
print(accumulator(3)) | |
print(x.send(2.3)) |
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 | |
def pali(l): | |
dic ={} | |
for i in l: | |
dic[i] = dic[i] +1 if i in dic else 1 | |
out = [ v % 2 for v in dic.values()] |
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 time | |
nb_repeat = 50 | |
def a_complex_operation(*args): | |
a = [] | |
for x in range(999999): | |
a.append(x) | |
return None |
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
M1719: |Labc|Ldce|Ebze| 0.20 0.30 0.32 0.32 0.32 0.32 0.263296394963 0.111387109786 0.470177600114 0.029771700191 0.173209325064 3.28129207574 |