@@ -62,7 +62,7 @@ def _atexit_print_fn():
6262 else :
6363 destination_file = config .profiling__destination
6464
65- with extended_open (destination_file , mode = "w" ):
65+ with extended_open (destination_file , mode = "w" ) as f :
6666 # Reverse sort in the order of compile+exec time
6767 for ps in sorted (
6868 _atexit_print_list , key = lambda a : a .compile_time + a .fct_call_time
@@ -73,7 +73,7 @@ def _atexit_print_fn():
7373 or getattr (ps , "callcount" , 0 ) > 1
7474 ):
7575 ps .summary (
76- file = destination_file ,
76+ file = f ,
7777 n_ops_to_print = config .profiling__n_ops ,
7878 n_apply_to_print = config .profiling__n_apply ,
7979 )
@@ -131,7 +131,7 @@ def _atexit_print_fn():
131131 cum .rewriter_profile = None
132132
133133 cum .summary (
134- file = destination_file ,
134+ file = f ,
135135 n_ops_to_print = config .profiling__n_ops ,
136136 n_apply_to_print = config .profiling__n_apply ,
137137 )
@@ -157,7 +157,7 @@ def print_global_stats():
157157 else :
158158 destination_file = config .profiling__destination
159159
160- with extended_open (destination_file , mode = "w" ):
160+ with extended_open (destination_file , mode = "w" ) as f :
161161 print ("=" * 50 , file = destination_file )
162162 print (
163163 (
@@ -167,9 +167,9 @@ def print_global_stats():
167167 "Time spent compiling PyTensor functions: "
168168 f"rewriting = { total_graph_rewrite_time :6.3f} s, linking = { total_time_linker :6.3f} s " ,
169169 ),
170- file = destination_file ,
170+ file = f ,
171171 )
172- print ("=" * 50 , file = destination_file )
172+ print ("=" * 50 , file = f )
173173
174174
175175_profiler_printers = []
0 commit comments