Construct FunctionRaise

Performance Diagrams

Construct FunctionRaise 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000CPython 3.10Nuitka (main)Nuitka (develop)Nuitka (factory)12192933588.11538461538461257.0CPython 3.1053354886240.03846153846155395.980511452991Nuitka (main)53354886391.96153846153845395.980511452991Nuitka (develop)53354886543.8846153846154395.980511452991Nuitka (factory)Construct FunctionRaiseTicks Construct FunctionRaise 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)11464046088.11538461538461257.0CPython 3.853502345240.03846153846155388.7874056234999Nuitka (main)53502345391.96153846153845388.7874056234999Nuitka (develop)53502345543.8846153846154388.7874056234999Nuitka (factory)Construct FunctionRaiseTicks Construct FunctionRaise 0040000000400000008000000080000000120000000120000000160000000160000000200000000200000000240000000240000000280000000280000000320000000320000000360000000360000000CPython 2.7Nuitka (main)Nuitka (develop)Nuitka (factory)36095165588.11538461538461257.0CPython 2.7124550609240.03846153846155418.84531805448916Nuitka (main)124550591391.96153846153845418.8453303776822Nuitka (develop)124550591543.8846153846154418.8453303776822Nuitka (factory)Construct FunctionRaiseTicks

Source Code with Construct

from __future__ import print_function

import itertools

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




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

print("OK.")

Source Code without Construct

from __future__ import print_function

import itertools

module_var = None


def raisy():
    raise TypeError


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

    # construct_begin




    # construct_alternative
    pass
    # construct_end


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

print("OK.")

Context Diff of Source Code


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

Context Diff of Generated Code


Construct
Baseline
220     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused; 220     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused;
221     PyObject *exception_type = NULL; 221     PyObject *exception_type = NULL;
222     PyObject *exception_value = NULL; 222     PyObject *exception_value = NULL;
223     PyTracebackObject *exception_tb = NULL; 223     PyTracebackObject *exception_tb = NULL;
224     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 224     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n 225     PyObject *exception_keeper_type_1; n
226     PyObject *exception_keeper_value_1;
227     PyTracebackObject *exception_keeper_tb_1;
228     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
229     int tmp_res;
230     bool tmp_result;
231     static struct Nuitka_FrameObject *cache_frame_f6f995f4518e26741f4b0c2e354d257c = NULL; 225     static struct Nuitka_FrameObject *cache_frame_f6f995f4518e26741f4b0c2e354d257c = NULL;
232     PyObject *tmp_return_value = NULL; 226     PyObject *tmp_return_value = NULL;
233 227
234     // Actual function body. 228     // Actual function body.
235     if (isFrameUnusable(cache_frame_f6f995f4518e26741f4b0c2e354d257c)) { 229     if (isFrameUnusable(cache_frame_f6f995f4518e26741f4b0c2e354d257c)) {
276             exception_lineno = 33; 270             exception_lineno = 33;
277             type_description_1 = "o"; 271             type_description_1 = "o";
278             goto frame_exception_exit_1; 272             goto frame_exception_exit_1;
279         } 273         }
280     } 274     }
n 281     // Tried code: n
282     {
283         PyObject *tmp_called_value_1;
284         PyObject *tmp_call_result_1;
285         CHECK_OBJECT(par_raisy);
286         tmp_called_value_1 = par_raisy;
287         frame_f6f995f4518e26741f4b0c2e354d257c->m_frame.f_lineno = 37;
288         tmp_call_result_1 = CALL_FUNCTION_NO_ARGS(tstate, tmp_called_value_1);
289         if (tmp_call_result_1 == NULL) {
290             assert(HAS_ERROR_OCCURRED(tstate));
291 275
n 292             FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb); n
293  
294  
295             exception_lineno = 37;
296             type_description_1 = "o";
297             goto try_except_handler_1;
298         }
299         Py_DECREF(tmp_call_result_1);
300     }
301     goto try_end_1;
302     // Exception handler code:
303     try_except_handler_1:;
304     exception_keeper_type_1 = exception_type;
305     exception_keeper_value_1 = exception_value;
306     exception_keeper_tb_1 = exception_tb;
307     exception_keeper_lineno_1 = exception_lineno;
308     exception_type = NULL;
309     exception_value = NULL;
310     exception_tb = NULL;
311     exception_lineno = 0;
312  
313     // Preserve existing published exception.
314     PRESERVE_FRAME_EXCEPTION(tstate, frame_f6f995f4518e26741f4b0c2e354d257c);
315     if (exception_keeper_tb_1 == NULL) {
316         exception_keeper_tb_1 = MAKE_TRACEBACK(frame_f6f995f4518e26741f4b0c2e354d257c, exception_keeper_lineno_1);
317     } else if (exception_keeper_lineno_1 != 0) {
318         exception_keeper_tb_1 = ADD_TRACEBACK(exception_keeper_tb_1, frame_f6f995f4518e26741f4b0c2e354d257c, exception_keeper_lineno_1);
319     }
320  
321     PUBLISH_CURRENT_EXCEPTION(tstate, &exception_keeper_type_1, &exception_keeper_value_1, &exception_keeper_tb_1);
322     {
323         bool tmp_condition_result_1;
324         PyObject *tmp_cmp_expr_left_1;
325         PyObject *tmp_cmp_expr_right_1;
326         tmp_cmp_expr_left_1 = EXC_TYPE(PyThreadState_GET());
327         tmp_cmp_expr_right_1 = PyExc_TypeError;
328         tmp_res = EXCEPTION_MATCH_BOOL(tstate, tmp_cmp_expr_left_1, tmp_cmp_expr_right_1);
329         assert(!(tmp_res == -1));
330         tmp_condition_result_1 = (tmp_res == 0) ? true : false;
331         if (tmp_condition_result_1 != false) {
332             goto branch_yes_1;
333         } else {
334             goto branch_no_1;
335         }
336     }
337     branch_yes_1:;
338     tmp_result = RERAISE_EXCEPTION(&exception_type, &exception_value, &exception_tb);
339     if (unlikely(tmp_result == false)) {
340         exception_lineno = 36;
341     }
342  
343     if (exception_tb && exception_tb->tb_frame == &frame_f6f995f4518e26741f4b0c2e354d257c->m_frame) frame_f6f995f4518e26741f4b0c2e354d257c->m_frame.f_lineno = exception_tb->tb_lineno;
344     type_description_1 = "o";
345     goto frame_exception_exit_1;
346     branch_no_1:;
347     goto try_end_1;
348     NUITKA_CANNOT_GET_HERE("exception handler codes exits in all cases");
349     return NULL;
350     // End of try:
351     try_end_1:;
352  
353     // Restore frame exception if necessary.
354     RESTORE_FRAME_EXCEPTION(tstate, frame_f6f995f4518e26741f4b0c2e354d257c);
355 276
356     // Put the previous frame back on top. 277     // Put the previous frame back on top.
357     popFrameStack(tstate); 278     popFrameStack(tstate);
358 279
359     goto frame_no_exception_1; 280     goto frame_no_exception_1;
360     frame_exception_exit_1: 281     frame_exception_exit_1:
361 282
t 362     RESTORE_FRAME_EXCEPTION(tstate, frame_f6f995f4518e26741f4b0c2e354d257c); t
363 283
364     if (exception_tb == NULL) { 284     if (exception_tb == NULL) {
365         exception_tb = MAKE_TRACEBACK(frame_f6f995f4518e26741f4b0c2e354d257c, exception_lineno); 285         exception_tb = MAKE_TRACEBACK(frame_f6f995f4518e26741f4b0c2e354d257c, exception_lineno);
366     } else if (exception_tb->tb_frame != &frame_f6f995f4518e26741f4b0c2e354d257c->m_frame) { 286     } else if (exception_tb->tb_frame != &frame_f6f995f4518e26741f4b0c2e354d257c->m_frame) {
367         exception_tb = ADD_TRACEBACK(exception_tb, frame_f6f995f4518e26741f4b0c2e354d257c, exception_lineno); 287         exception_tb = ADD_TRACEBACK(exception_tb, frame_f6f995f4518e26741f4b0c2e354d257c, exception_lineno);