Construct FunctionRaise

Performance Diagrams

Construct FunctionRaise 0040000000400000008000000080000000120000000120000000160000000160000000200000000200000000240000000240000000280000000280000000320000000320000000360000000360000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)36365222688.11538461538461257.0CPython 2.7145603580240.03846153846155405.17226781159275Nuitka (master)145603483391.96153846153845405.1723337267463Nuitka (develop)145603483543.8846153846154405.1723337267463Nuitka (factory)Construct FunctionRaiseTicks Construct FunctionRaise 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000CPython 3.8Nuitka (master)Nuitka (develop)Nuitka (factory)12378526888.11538461538461257.0CPython 3.867151704240.03846153846155370.0588896087376Nuitka (master)67151700391.96153846153845370.0588975940299Nuitka (develop)67151700543.8846153846154370.0588975940299Nuitka (factory)Construct FunctionRaiseTicks

Source Code with Construct

from __future__ import print_function

module_var = None

def raisy():
    raise TypeError

def calledRepeatedly(raisy):
    # Force a frame for now
    module_var

# construct_begin
    try:
        raisy()
    except TypeError:
        pass
# construct_alternative



import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly(raisy)

print("OK.")

Source Code without Construct

from __future__ import print_function

module_var = None

def raisy():
    raise TypeError

def calledRepeatedly(raisy):
    # Force a frame for now
    module_var

# construct_begin




# construct_alternative
    pass
# construct_end

import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly(raisy)

print("OK.")

Context Diff of Source Code


Construct
Baseline
28 def calledRepeatedly(raisy): 28 def calledRepeatedly(raisy):
29     # Force a frame for now 29     # Force a frame for now
30     module_var 30     module_var
31 31
32 # construct_begin 32 # construct_begin
n 33     try: n
34         raisy()
35     except TypeError:
36         pass
37 # construct_alternative
38 33
39 34
t t 35  
36  
37 # construct_alternative
38     pass
39 # construct_end
40 40
41 import itertools 41 import itertools
42 for x in itertools.repeat(None, 50000): 42 for x in itertools.repeat(None, 50000):
43     calledRepeatedly(raisy) 43     calledRepeatedly(raisy)
44 44

Context Diff of Generated Code


Construct
Baseline
215     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused; 215     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused;
216     PyObject *exception_type = NULL; 216     PyObject *exception_type = NULL;
217     PyObject *exception_value = NULL; 217     PyObject *exception_value = NULL;
218     PyTracebackObject *exception_tb = NULL; 218     PyTracebackObject *exception_tb = NULL;
219     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 219     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n n 220     static struct Nuitka_FrameObject *cache_frame_5aac4680b91edcb64e23ace3844879de = NULL;
221     PyObject *tmp_return_value = NULL;
220     PyObject *exception_keeper_type_1; 222     PyObject *exception_keeper_type_1;
221     PyObject *exception_keeper_value_1; 223     PyObject *exception_keeper_value_1;
222     PyTracebackObject *exception_keeper_tb_1; 224     PyTracebackObject *exception_keeper_tb_1;
223     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 225     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
n 224     PyObject *exception_preserved_type_1; n
225     PyObject *exception_preserved_value_1;
226     PyTracebackObject *exception_preserved_tb_1;
227     int tmp_res;
228     bool tmp_result;
229     PyObject *exception_keeper_type_2;
230     PyObject *exception_keeper_value_2;
231     PyTracebackObject *exception_keeper_tb_2;
232     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_2;
233     static struct Nuitka_FrameObject *cache_frame_5aac4680b91edcb64e23ace3844879de = NULL;
234     PyObject *tmp_return_value = NULL;
235     PyObject *exception_keeper_type_3;
236     PyObject *exception_keeper_value_3;
237     PyTracebackObject *exception_keeper_tb_3;
238     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_3;
239 226
240     // Actual function body. 227     // Actual function body.
241     // Tried code: 228     // Tried code:
242     if (isFrameUnusable(cache_frame_5aac4680b91edcb64e23ace3844879de)) { 229     if (isFrameUnusable(cache_frame_5aac4680b91edcb64e23ace3844879de)) {
243         Py_XDECREF(cache_frame_5aac4680b91edcb64e23ace3844879de); 230         Py_XDECREF(cache_frame_5aac4680b91edcb64e23ace3844879de);
283             exception_lineno = 30; 270             exception_lineno = 30;
284             type_description_1 = "o"; 271             type_description_1 = "o";
285             goto frame_exception_exit_1; 272             goto frame_exception_exit_1;
286         } 273         }
287     } 274     }
n 288     // Tried code: n
289     {
290         PyObject *tmp_called_name_1;
291         PyObject *tmp_call_result_1;
292         CHECK_OBJECT(par_raisy);
293         tmp_called_name_1 = par_raisy;
294         frame_5aac4680b91edcb64e23ace3844879de->m_frame.f_lineno = 34;
295         tmp_call_result_1 = CALL_FUNCTION_NO_ARGS(tmp_called_name_1);
296         if (tmp_call_result_1 == NULL) {
297             assert(ERROR_OCCURRED());
298  
299             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
300  
301  
302             exception_lineno = 34;
303             type_description_1 = "o";
304             goto try_except_handler_2;
305         }
306         Py_DECREF(tmp_call_result_1);
307     }
308     goto try_end_1;
309     // Exception handler code:
310     try_except_handler_2:;
311     exception_keeper_type_1 = exception_type;
312     exception_keeper_value_1 = exception_value;
313     exception_keeper_tb_1 = exception_tb;
314     exception_keeper_lineno_1 = exception_lineno;
315     exception_type = NULL;
316     exception_value = NULL;
317     exception_tb = NULL;
318     exception_lineno = 0;
319  
320     // Preserve existing published exception id 1.
321     GET_CURRENT_EXCEPTION(&exception_preserved_type_1, &exception_preserved_value_1, &exception_preserved_tb_1);
322  
323     if (exception_keeper_tb_1 == NULL) {
324         exception_keeper_tb_1 = MAKE_TRACEBACK(frame_5aac4680b91edcb64e23ace3844879de, exception_keeper_lineno_1);
325     } else if (exception_keeper_lineno_1 != 0) {
326         exception_keeper_tb_1 = ADD_TRACEBACK(exception_keeper_tb_1, frame_5aac4680b91edcb64e23ace3844879de, exception_keeper_lineno_1);
327     }
328  
329     NORMALIZE_EXCEPTION(&exception_keeper_type_1, &exception_keeper_value_1, &exception_keeper_tb_1);
330     ATTACH_TRACEBACK_TO_EXCEPTION_VALUE(exception_keeper_value_1, exception_keeper_tb_1);
331     PUBLISH_EXCEPTION(&exception_keeper_type_1, &exception_keeper_value_1, &exception_keeper_tb_1);
332     // Tried code:
333     {
334         bool tmp_condition_result_1;
335         PyObject *tmp_compexpr_left_1;
336         PyObject *tmp_compexpr_right_1;
337         tmp_compexpr_left_1 = EXC_TYPE(PyThreadState_GET());
338         tmp_compexpr_right_1 = PyExc_TypeError;
339         tmp_res = EXCEPTION_MATCH_BOOL(tmp_compexpr_left_1, tmp_compexpr_right_1);
340         assert(!(tmp_res == -1));
341         tmp_condition_result_1 = (tmp_res == 0) ? true : false;
342         if (tmp_condition_result_1 != false) {
343             goto branch_yes_1;
344         } else {
345             goto branch_no_1;
346         }
347     }
348     branch_yes_1:;
349     tmp_result = RERAISE_EXCEPTION(&exception_type, &exception_value, &exception_tb);
350     if (unlikely(tmp_result == false)) {
351         exception_lineno = 33;
352     }
353  
354     if (exception_tb && exception_tb->tb_frame == &frame_5aac4680b91edcb64e23ace3844879de->m_frame) frame_5aac4680b91edcb64e23ace3844879de->m_frame.f_lineno = exception_tb->tb_lineno;
355     type_description_1 = "o";
356     goto try_except_handler_3;
357     branch_no_1:;
358     goto try_end_2;
359     // Exception handler code:
360     try_except_handler_3:;
361     exception_keeper_type_2 = exception_type;
362     exception_keeper_value_2 = exception_value;
363     exception_keeper_tb_2 = exception_tb;
364     exception_keeper_lineno_2 = exception_lineno;
365     exception_type = NULL;
366     exception_value = NULL;
367     exception_tb = NULL;
368     exception_lineno = 0;
369  
370     // Restore previous exception id 1.
371     SET_CURRENT_EXCEPTION(exception_preserved_type_1, exception_preserved_value_1, exception_preserved_tb_1);
372  
373     // Re-raise.
374     exception_type = exception_keeper_type_2;
375     exception_value = exception_keeper_value_2;
376     exception_tb = exception_keeper_tb_2;
377     exception_lineno = exception_keeper_lineno_2;
378  
379     goto frame_exception_exit_1;
380     // End of try:
381     try_end_2:;
382     // Restore previous exception id 1.
383     SET_CURRENT_EXCEPTION(exception_preserved_type_1, exception_preserved_value_1, exception_preserved_tb_1);
384  
385     goto try_end_1;
386     NUITKA_CANNOT_GET_HERE("exception handler codes exits in all cases");
387     return NULL;
388     // End of try:
389     try_end_1:;
390 275
391 #if 0 276 #if 0
392     RESTORE_FRAME_EXCEPTION(frame_5aac4680b91edcb64e23ace3844879de); 277     RESTORE_FRAME_EXCEPTION(frame_5aac4680b91edcb64e23ace3844879de);
393 #endif 278 #endif
394 279
448     Py_DECREF(par_raisy); 333     Py_DECREF(par_raisy);
449     par_raisy = NULL; 334     par_raisy = NULL;
450     goto function_return_exit; 335     goto function_return_exit;
451     // Exception handler code: 336     // Exception handler code:
452     try_except_handler_1:; 337     try_except_handler_1:;
n 453     exception_keeper_type_3 = exception_type; n 338     exception_keeper_type_1 = exception_type;
454     exception_keeper_value_3 = exception_value; 339     exception_keeper_value_1 = exception_value;
455     exception_keeper_tb_3 = exception_tb; 340     exception_keeper_tb_1 = exception_tb;
456     exception_keeper_lineno_3 = exception_lineno; 341     exception_keeper_lineno_1 = exception_lineno;
457     exception_type = NULL; 342     exception_type = NULL;
458     exception_value = NULL; 343     exception_value = NULL;
459     exception_tb = NULL; 344     exception_tb = NULL;
460     exception_lineno = 0; 345     exception_lineno = 0;
461 346
462     CHECK_OBJECT(par_raisy); 347     CHECK_OBJECT(par_raisy);
463     Py_DECREF(par_raisy); 348     Py_DECREF(par_raisy);
464     par_raisy = NULL; 349     par_raisy = NULL;
465     // Re-raise. 350     // Re-raise.
t 466     exception_type = exception_keeper_type_3; t 351     exception_type = exception_keeper_type_1;
467     exception_value = exception_keeper_value_3; 352     exception_value = exception_keeper_value_1;
468     exception_tb = exception_keeper_tb_3; 353     exception_tb = exception_keeper_tb_1;
469     exception_lineno = exception_keeper_lineno_3; 354     exception_lineno = exception_keeper_lineno_1;
470 355
471     goto function_exception_exit; 356     goto function_exception_exit;
472     // End of try: 357     // End of try:
473 358
474     NUITKA_CANNOT_GET_HERE("Return statement must have exited already."); 359     NUITKA_CANNOT_GET_HERE("Return statement must have exited already.");