Construct FunctionRaise

Performance Diagrams

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