File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ import random
2+ import time
3+
4+
5+ def benchmark (func ):
6+ def wrapper (* args , ** kwargs ):
7+ t = time .perf_counter ()
8+ res = func (* args , ** kwargs )
9+ print (f"{ func .__name__ } { time .perf_counter ()- t } " )
10+ return res
11+ return wrapper
12+
13+ @benchmark
14+ def random_tree (n ):
15+ temp = [n for n in range (n )]
16+ for i in range (n + 1 ):
17+ temp [random .choice (temp )] = random .choice (temp )
18+ return temp
19+
20+
21+ if __name__ == '__main__' :
22+ random_tree (10000 )
Original file line number Diff line number Diff line change 1+ class A (object ):
2+ def foo (self , x ):
3+ print (f"foo({ self } , { x } ) 실행" )
4+
5+ @classmethod
6+ def class_foo (cls , x ):
7+ print (f"class_foo({ cls } , { x } ) 실행" )
8+
9+ @staticmethod
10+ def static_foo (x ):
11+ print (f"static_foo({ x } ) 실행" )
12+
13+ if __name__ == '__main__' :
14+ a = A ()
15+ a .foo (1 )
16+ a .class_foo (2 )
17+ A .class_foo (2 )
18+ a .static_foo (3 )
19+ A .static_foo (3 )
You can’t perform that action at this time.
0 commit comments