File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import datetime
2+ from dis import dis
3+
4+
5+ def troubling_method (x : str ) -> int :
6+ # print(f"We will take a shot at converting {x}")
7+
8+ try :
9+ return int (x )
10+ except ValueError as ve :
11+ print (f"Oh no, it couldn't be converted because of values: { ve } " )
12+ except NotImplementedError :
13+ print ("Somehow not implemented?" )
14+ except :
15+ print ("We have no idea" )
16+
17+ # print("There was some kind of error")
18+ return - 1
19+
20+
21+ def main ():
22+ troubling_method ("77" )
23+
24+ # print(troubling_method("77"))
25+ # print(troubling_method("901"))
26+ # # print(troubling_method(902))
27+ # print(troubling_method("Nine hundred"))
28+ #
29+ # dis(troubling_method)
30+
31+ times = 10_000_000
32+ t0 = datetime .datetime .now ()
33+
34+ for _ in range (times ):
35+ troubling_method ("77" )
36+
37+ t1 = datetime .datetime .now ()
38+ dt = t1 - t0
39+ print (f"Done in { dt .total_seconds ()* 1000 :,.2f} ms" )
40+
41+
42+ if __name__ == '__main__' :
43+ main ()
You can’t perform that action at this time.
0 commit comments