Construct FunctionRaise

Performance Diagrams

Construct FunctionRaise 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000CPython 3.10Nuitka (main)Nuitka (develop)Nuitka (factory)12192996088.11538461538461257.0CPython 3.1053396061240.03846153846155395.8976163904009Nuitka (main)53400345391.96153846153845395.88893400989576Nuitka (develop)53450382543.8846153846154395.7875240488001Nuitka (factory)Construct FunctionRaiseTicks Construct FunctionRaise 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)11464096288.11538461538461257.0CPython 3.853501730240.03846153846155388.7892363008017Nuitka (main)53502502391.96153846153845388.7875722090705Nuitka (develop)53550675543.8846153846154388.68373245393065Nuitka (factory)Construct FunctionRaiseTicks Construct FunctionRaise 0040000000400000008000000080000000120000000120000000160000000160000000200000000200000000240000000240000000280000000280000000320000000320000000360000000360000000CPython 2.7Nuitka (main)Nuitka (develop)Nuitka (factory)36005173188.11538461538461257.0CPython 2.7124550609240.03846153846155418.6321915152371Nuitka (main)123950337391.96153846153845419.04417799768464Nuitka (develop)123850485543.8846153846154419.11270972037926Nuitka (factory)Construct FunctionRaiseTicks

Source Code with Construct

    try:
        raisy()
    except TypeError:
        pass
    # construct_alternative




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

print("OK.")

#     Python test originally created or extracted from other peoples work. The
#     parts from me are licensed as below. It is at least Free Software where
#     it's copied from other people. In these cases, that will normally be
#     indicated.
#
#     Licensed under the Apache License, Version 2.0 (the "License");
#     you may not use this file except in compliance with the License.
#     You may obtain a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#     Unless required by applicable law or agreed to in writing, software
#     distributed under the License is distributed on an "AS IS" BASIS,
#     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#     See the License for the specific language governing permissions and
#     limitations under the License.

Source Code without Construct

    # construct_alternative
    pass
    # construct_end


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

print("OK.")

#     Python test originally created or extracted from other peoples work. The
#     parts from me are licensed as below. It is at least Free Software where
#     it's copied from other people. In these cases, that will normally be
#     indicated.
#
#     Licensed under the Apache License, Version 2.0 (the "License");
#     you may not use this file except in compliance with the License.
#     You may obtain a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#     Unless required by applicable law or agreed to in writing, software
#     distributed under the License is distributed on an "AS IS" BASIS,
#     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#     See the License for the specific language governing permissions and
#     limitations under the License.

Context Diff of Source Code


Construct
Baseline
15 def calledRepeatedly(raisy): 15 def calledRepeatedly(raisy):
16     # Force a frame for now 16     # Force a frame for now
17     module_var 17     module_var
18 18
19     # construct_begin 19     # construct_begin
n 20     try: n
21         raisy()
22     except TypeError:
23         pass
24     # construct_alternative
25 20
26 21
t t 22  
23  
24     # construct_alternative
25     pass
26     # construct_end
27 27
28 28
29 for x in itertools.repeat(None, 50000): 29 for x in itertools.repeat(None, 50000):
30     calledRepeatedly(raisy) 30     calledRepeatedly(raisy)
31 31

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_615b4c99237900cf18c1229684fc8a1b = NULL; 225     static struct Nuitka_FrameObject *cache_frame_615b4c99237900cf18c1229684fc8a1b = 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_615b4c99237900cf18c1229684fc8a1b)) { 229     if (isFrameUnusable(cache_frame_615b4c99237900cf18c1229684fc8a1b)) {
276             exception_lineno = 17; 270             exception_lineno = 17;
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_615b4c99237900cf18c1229684fc8a1b->m_frame.f_lineno = 21;
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 = 21;
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_615b4c99237900cf18c1229684fc8a1b);
315     if (exception_keeper_tb_1 == NULL) {
316         exception_keeper_tb_1 = MAKE_TRACEBACK(frame_615b4c99237900cf18c1229684fc8a1b, exception_keeper_lineno_1);
317     } else if (exception_keeper_lineno_1 != 0) {
318         exception_keeper_tb_1 = ADD_TRACEBACK(exception_keeper_tb_1, frame_615b4c99237900cf18c1229684fc8a1b, 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 = 20;
341     }
342  
343     if (exception_tb && exception_tb->tb_frame == &frame_615b4c99237900cf18c1229684fc8a1b->m_frame) frame_615b4c99237900cf18c1229684fc8a1b->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_615b4c99237900cf18c1229684fc8a1b);
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_615b4c99237900cf18c1229684fc8a1b); t
363 283
364     if (exception_tb == NULL) { 284     if (exception_tb == NULL) {
365         exception_tb = MAKE_TRACEBACK(frame_615b4c99237900cf18c1229684fc8a1b, exception_lineno); 285         exception_tb = MAKE_TRACEBACK(frame_615b4c99237900cf18c1229684fc8a1b, exception_lineno);
366     } else if (exception_tb->tb_frame != &frame_615b4c99237900cf18c1229684fc8a1b->m_frame) { 286     } else if (exception_tb->tb_frame != &frame_615b4c99237900cf18c1229684fc8a1b->m_frame) {
367         exception_tb = ADD_TRACEBACK(exception_tb, frame_615b4c99237900cf18c1229684fc8a1b, exception_lineno); 287         exception_tb = ADD_TRACEBACK(exception_tb, frame_615b4c99237900cf18c1229684fc8a1b, exception_lineno);