Construct FunctionRaise

Performance Diagrams

Construct FunctionRaise 0040000000400000008000000080000000120000000120000000160000000160000000200000000200000000240000000240000000280000000280000000320000000320000000360000000360000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)36365222688.11538461538461257.0CPython 2.7145503483240.03846153846155405.2402874932703Nuitka (master)124650476391.96153846153845419.41069118328454Nuitka (develop)124650476543.8846153846154419.41069118328454Nuitka (factory)Construct FunctionRaiseTicks Construct FunctionRaise 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000CPython 3.8Nuitka (master)Nuitka (develop)Nuitka (factory)12378526888.11538461538461257.0CPython 3.862751691240.03846153846155378.8427370113841Nuitka (master)63052017391.96153846153845378.2431892929916Nuitka (develop)63052017543.8846153846154378.2431892929916Nuitka (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
227     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused; 227     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused;
228     PyObject *exception_type = NULL; 228     PyObject *exception_type = NULL;
229     PyObject *exception_value = NULL; 229     PyObject *exception_value = NULL;
230     PyTracebackObject *exception_tb = NULL; 230     PyTracebackObject *exception_tb = NULL;
231     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 231     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n 232     PyObject *exception_keeper_type_1; n
233     PyObject *exception_keeper_value_1;
234     PyTracebackObject *exception_keeper_tb_1;
235     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
236     PyObject *exception_preserved_type_1;
237     PyObject *exception_preserved_value_1;
238     PyTracebackObject *exception_preserved_tb_1;
239     int tmp_res;
240     bool tmp_result;
241     PyObject *exception_keeper_type_2;
242     PyObject *exception_keeper_value_2;
243     PyTracebackObject *exception_keeper_tb_2;
244     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_2;
245     static struct Nuitka_FrameObject *cache_frame_27831bd38807eb9d339ee5094ef91e1f = NULL; 232     static struct Nuitka_FrameObject *cache_frame_27831bd38807eb9d339ee5094ef91e1f = NULL;
246     PyObject *tmp_return_value = NULL; 233     PyObject *tmp_return_value = NULL;
247 234
248     // Actual function body. 235     // Actual function body.
249     if (isFrameUnusable(cache_frame_27831bd38807eb9d339ee5094ef91e1f)) { 236     if (isFrameUnusable(cache_frame_27831bd38807eb9d339ee5094ef91e1f)) {
290             exception_lineno = 30; 277             exception_lineno = 30;
291             type_description_1 = "o"; 278             type_description_1 = "o";
292             goto frame_exception_exit_1; 279             goto frame_exception_exit_1;
293         } 280         }
294     } 281     }
t 295     // Tried code: t
296     {
297         PyObject *tmp_called_name_1;
298         PyObject *tmp_call_result_1;
299         CHECK_OBJECT(par_raisy);
300         tmp_called_name_1 = par_raisy;
301         frame_27831bd38807eb9d339ee5094ef91e1f->m_frame.f_lineno = 34;
302         tmp_call_result_1 = CALL_FUNCTION_NO_ARGS(tmp_called_name_1);
303         if (tmp_call_result_1 == NULL) {
304             assert(ERROR_OCCURRED());
305  
306             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
307  
308  
309             exception_lineno = 34;
310             type_description_1 = "o";
311             goto try_except_handler_1;
312         }
313         Py_DECREF(tmp_call_result_1);
314     }
315     goto try_end_1;
316     // Exception handler code:
317     try_except_handler_1:;
318     exception_keeper_type_1 = exception_type;
319     exception_keeper_value_1 = exception_value;
320     exception_keeper_tb_1 = exception_tb;
321     exception_keeper_lineno_1 = exception_lineno;
322     exception_type = NULL;
323     exception_value = NULL;
324     exception_tb = NULL;
325     exception_lineno = 0;
326  
327     // Preserve existing published exception id 1.
328     GET_CURRENT_EXCEPTION(&exception_preserved_type_1, &exception_preserved_value_1, &exception_preserved_tb_1);
329  
330     if (exception_keeper_tb_1 == NULL) {
331         exception_keeper_tb_1 = MAKE_TRACEBACK(frame_27831bd38807eb9d339ee5094ef91e1f, exception_keeper_lineno_1);
332     } else if (exception_keeper_lineno_1 != 0) {
333         exception_keeper_tb_1 = ADD_TRACEBACK(exception_keeper_tb_1, frame_27831bd38807eb9d339ee5094ef91e1f, exception_keeper_lineno_1);
334     }
335  
336     NORMALIZE_EXCEPTION(&exception_keeper_type_1, &exception_keeper_value_1, &exception_keeper_tb_1);
337     ATTACH_TRACEBACK_TO_EXCEPTION_VALUE(exception_keeper_value_1, exception_keeper_tb_1);
338     PUBLISH_EXCEPTION(&exception_keeper_type_1, &exception_keeper_value_1, &exception_keeper_tb_1);
339     // Tried code:
340     {
341         bool tmp_condition_result_1;
342         PyObject *tmp_compexpr_left_1;
343         PyObject *tmp_compexpr_right_1;
344         tmp_compexpr_left_1 = EXC_TYPE(PyThreadState_GET());
345         tmp_compexpr_right_1 = PyExc_TypeError;
346         tmp_res = EXCEPTION_MATCH_BOOL(tmp_compexpr_left_1, tmp_compexpr_right_1);
347         assert(!(tmp_res == -1));
348         tmp_condition_result_1 = (tmp_res == 0) ? true : false;
349         if (tmp_condition_result_1 != false) {
350             goto branch_yes_1;
351         } else {
352             goto branch_no_1;
353         }
354     }
355     branch_yes_1:;
356     tmp_result = RERAISE_EXCEPTION(&exception_type, &exception_value, &exception_tb);
357     if (unlikely(tmp_result == false)) {
358         exception_lineno = 33;
359     }
360  
361     if (exception_tb && exception_tb->tb_frame == &frame_27831bd38807eb9d339ee5094ef91e1f->m_frame) frame_27831bd38807eb9d339ee5094ef91e1f->m_frame.f_lineno = exception_tb->tb_lineno;
362     type_description_1 = "o";
363     goto try_except_handler_2;
364     branch_no_1:;
365     goto try_end_2;
366     // Exception handler code:
367     try_except_handler_2:;
368     exception_keeper_type_2 = exception_type;
369     exception_keeper_value_2 = exception_value;
370     exception_keeper_tb_2 = exception_tb;
371     exception_keeper_lineno_2 = exception_lineno;
372     exception_type = NULL;
373     exception_value = NULL;
374     exception_tb = NULL;
375     exception_lineno = 0;
376  
377     // Restore previous exception id 1.
378     SET_CURRENT_EXCEPTION(exception_preserved_type_1, exception_preserved_value_1, exception_preserved_tb_1);
379  
380     // Re-raise.
381     exception_type = exception_keeper_type_2;
382     exception_value = exception_keeper_value_2;
383     exception_tb = exception_keeper_tb_2;
384     exception_lineno = exception_keeper_lineno_2;
385  
386     goto frame_exception_exit_1;
387     // End of try:
388     try_end_2:;
389     // Restore previous exception id 1.
390     SET_CURRENT_EXCEPTION(exception_preserved_type_1, exception_preserved_value_1, exception_preserved_tb_1);
391  
392     goto try_end_1;
393     NUITKA_CANNOT_GET_HERE("exception handler codes exits in all cases");
394     return NULL;
395     // End of try:
396     try_end_1:;
397 282
398 #if 0 283 #if 0
399     RESTORE_FRAME_EXCEPTION(frame_27831bd38807eb9d339ee5094ef91e1f); 284     RESTORE_FRAME_EXCEPTION(frame_27831bd38807eb9d339ee5094ef91e1f);
400 #endif 285 #endif
401 286