Construct ClosureVariableAccess

Performance Diagrams

Construct ClosureVariableAccess 001000000100000020000002000000300000030000004000000400000050000005000000600000060000007000000700000080000008000000CPython 3.10Nuitka (main)Nuitka (develop)Nuitka (factory)857331989.78846153846155257.0CPython 3.104749574244.59615384615387367.2147507104488Nuitka (main)4750255399.4038461538462367.1951217223144Nuitka (develop)4749998554.2115384615385367.20252943149285Nuitka (factory)Construct ClosureVariableAccessTicks Construct ClosureVariableAccess 001000000100000020000002000000300000030000004000000400000050000005000000600000060000007000000700000080000008000000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)842372989.78846153846155257.0CPython 3.84650530244.59615384615387367.68916415941027Nuitka (main)4650534399.4038461538462367.6890468168962Nuitka (develop)4650538554.2115384615385367.6889294743822Nuitka (factory)Construct ClosureVariableAccessTicks Construct ClosureVariableAccess 0010000001000000200000020000003000000300000040000004000000500000050000006000000600000070000007000000CPython 2.7Nuitka (main)Nuitka (develop)Nuitka (factory)724436489.78846153846155257.0CPython 2.73000088244.59615384615387401.778188417071Nuitka (main)3000088399.4038461538462401.778188417071Nuitka (develop)3000088554.2115384615385401.778188417071Nuitka (factory)Construct ClosureVariableAccessTicks

Source Code with Construct

        # construct_begin
        module_value2 = closure_value
        # construct_end

        module_value3 = closure_value

    f()


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

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_begin



        module_value3 = closure_value

    f()


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

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
17 17
18         # Use writing to global variable as access method. 18         # Use writing to global variable as access method.
19         global module_value2, module_value3 19         global module_value2, module_value3
20 20
21         # construct_begin 21         # construct_begin
t 22         module_value2 = closure_value t 22  
23         # construct_end 23  
24 24
25         module_value3 = closure_value 25         module_value3 = closure_value
26 26
27     f() 27     f()
28 28

Context Diff of Generated Code


Construct
Baseline
83 static PyCodeObject *codeobj_46dbb024f0826187ed4dc784f8b5719a; 83 static PyCodeObject *codeobj_46dbb024f0826187ed4dc784f8b5719a;
84 /* For use in "MainProgram.c". */ 84 /* For use in "MainProgram.c". */
85 PyCodeObject *codeobj_main = NULL; 85 PyCodeObject *codeobj_main = NULL;
86 86
87 static void createModuleCodeObjects(void) { 87 static void createModuleCodeObjects(void) {
n 88     module_filename_obj = mod_consts[6]; CHECK_OBJECT(module_filename_obj); n 88     module_filename_obj = mod_consts[5]; CHECK_OBJECT(module_filename_obj);
89     codeobj_b8dd5304dbdcb75df56b24282c513cef = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[15], mod_consts[15], NULL, NULL, 0, 0, 0); 89     codeobj_b8dd5304dbdcb75df56b24282c513cef = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[15], mod_consts[15], NULL, NULL, 0, 0, 0);
90     codeobj_main = codeobj_b8dd5304dbdcb75df56b24282c513cef; 90     codeobj_main = codeobj_b8dd5304dbdcb75df56b24282c513cef;
91     codeobj_ea734cafc2a0aa2fb92523887605c5b9 = MAKE_CODE_OBJECT(module_filename_obj, 11, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[10], mod_consts[10], mod_consts[16], NULL, 0, 0, 0); 91     codeobj_ea734cafc2a0aa2fb92523887605c5b9 = MAKE_CODE_OBJECT(module_filename_obj, 11, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[10], mod_consts[10], mod_consts[16], NULL, 0, 0, 0);
92     codeobj_46dbb024f0826187ed4dc784f8b5719a = MAKE_CODE_OBJECT(module_filename_obj, 14, CO_OPTIMIZED | CO_NEWLOCALS, mod_consts[1], mod_consts[17], mod_consts[18], mod_consts[18], 0, 0, 0); 92     codeobj_46dbb024f0826187ed4dc784f8b5719a = MAKE_CODE_OBJECT(module_filename_obj, 14, CO_OPTIMIZED | CO_NEWLOCALS, mod_consts[1], mod_consts[17], mod_consts[18], mod_consts[18], 0, 0, 0);
93 } 93 }
378         if (Nuitka_Cell_GET(self->m_closure[0]) == NULL) { 378         if (Nuitka_Cell_GET(self->m_closure[0]) == NULL) {
379 379
380             FORMAT_UNBOUND_CLOSURE_ERROR(&exception_type, &exception_value, mod_consts[2]); 380             FORMAT_UNBOUND_CLOSURE_ERROR(&exception_type, &exception_value, mod_consts[2]);
381             exception_tb = NULL; 381             exception_tb = NULL;
382 382
n 383             exception_lineno = 22; n
384             type_description_1 = "c";
385             goto frame_exception_exit_1;
386         }
387  
388         tmp_assign_source_1 = Nuitka_Cell_GET(self->m_closure[0]);
389         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_1);
390     }
391     {
392         PyObject *tmp_assign_source_2;
393         if (Nuitka_Cell_GET(self->m_closure[0]) == NULL) {
394  
395             FORMAT_UNBOUND_CLOSURE_ERROR(&exception_type, &exception_value, mod_consts[2]);
396             exception_tb = NULL;
397  
398             exception_lineno = 25; 383             exception_lineno = 25;
399             type_description_1 = "c"; 384             type_description_1 = "c";
400             goto frame_exception_exit_1; 385             goto frame_exception_exit_1;
401         } 386         }
402 387
n 403         tmp_assign_source_2 = Nuitka_Cell_GET(self->m_closure[0]); n 388         tmp_assign_source_1 = Nuitka_Cell_GET(self->m_closure[0]);
404         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_2); 389         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_1);
405     } 390     }
406 391
407 392
408     // Put the previous frame back on top. 393     // Put the previous frame back on top.
409     popFrameStack(tstate); 394     popFrameStack(tstate);
880 865
881     // Module code. 866     // Module code.
882     { 867     {
883         PyObject *tmp_assign_source_1; 868         PyObject *tmp_assign_source_1;
884         tmp_assign_source_1 = Py_None; 869         tmp_assign_source_1 = Py_None;
n 885         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_1); n 870         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_1);
886     } 871     }
887     { 872     {
888         PyObject *tmp_assign_source_2; 873         PyObject *tmp_assign_source_2;
n 889         tmp_assign_source_2 = mod_consts[6]; n 874         tmp_assign_source_2 = mod_consts[5];
890         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_2); 875         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_2);
891     } 876     }
892     frame_b8dd5304dbdcb75df56b24282c513cef = MAKE_MODULE_FRAME(codeobj_b8dd5304dbdcb75df56b24282c513cef, module___main__); 877     frame_b8dd5304dbdcb75df56b24282c513cef = MAKE_MODULE_FRAME(codeobj_b8dd5304dbdcb75df56b24282c513cef, module___main__);
893 878
894     // Push the new frame as the currently active one, and we should be exclusively 879     // Push the new frame as the currently active one, and we should be exclusively
895     // owning it. 880     // owning it.
901         PyObject *tmp_assign_source_3; 886         PyObject *tmp_assign_source_3;
902         PyObject *tmp_name_value_1; 887         PyObject *tmp_name_value_1;
903         PyObject *tmp_globals_arg_value_1; 888         PyObject *tmp_globals_arg_value_1;
904         PyObject *tmp_locals_arg_value_1; 889         PyObject *tmp_locals_arg_value_1;
905         PyObject *tmp_fromlist_value_1; 890         PyObject *tmp_fromlist_value_1;
n 906         tmp_name_value_1 = mod_consts[8]; n 891         tmp_name_value_1 = mod_consts[7];
907         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__; 892         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__;
908         tmp_locals_arg_value_1 = Py_None; 893         tmp_locals_arg_value_1 = Py_None;
909         tmp_fromlist_value_1 = Py_None; 894         tmp_fromlist_value_1 = Py_None;
910         frame_b8dd5304dbdcb75df56b24282c513cef->m_frame.f_lineno = 4; 895         frame_b8dd5304dbdcb75df56b24282c513cef->m_frame.f_lineno = 4;
911         tmp_assign_source_3 = IMPORT_MODULE4(tstate, tmp_name_value_1, tmp_globals_arg_value_1, tmp_locals_arg_value_1, tmp_fromlist_value_1); 896         tmp_assign_source_3 = IMPORT_MODULE4(tstate, tmp_name_value_1, tmp_globals_arg_value_1, tmp_locals_arg_value_1, tmp_fromlist_value_1);
917 902
918             exception_lineno = 4; 903             exception_lineno = 4;
919 904
920             goto frame_exception_exit_1; 905             goto frame_exception_exit_1;
921         } 906         }
n 922         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[8], tmp_assign_source_3); n 907         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_3);
923     } 908     }
924     { 909     {
925         PyObject *tmp_assign_source_4; 910         PyObject *tmp_assign_source_4;
n 926         tmp_assign_source_4 = mod_consts[9]; n 911         tmp_assign_source_4 = mod_consts[8];
927         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_4); 912         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_4);
928     } 913     }
929     { 914     {
930         PyObject *tmp_assign_source_5; 915         PyObject *tmp_assign_source_5;
931         tmp_assign_source_5 = Py_None; 916         tmp_assign_source_5 = Py_None;
n 932         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_5); n 917         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[9], tmp_assign_source_5);
933     } 918     }
934     { 919     {
935         PyObject *tmp_assign_source_6; 920         PyObject *tmp_assign_source_6;
936         tmp_assign_source_6 = Py_None; 921         tmp_assign_source_6 = Py_None;
n 937         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_6); n 922         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_6);
938     } 923     }
939     { 924     {
940         PyObject *tmp_assign_source_7; 925         PyObject *tmp_assign_source_7;
941 926
942 927
946     } 931     }
947     { 932     {
948         PyObject *tmp_assign_source_8; 933         PyObject *tmp_assign_source_8;
949         PyObject *tmp_iter_arg_1; 934         PyObject *tmp_iter_arg_1;
950         PyObject *tmp_called_instance_1; 935         PyObject *tmp_called_instance_1;
n 951         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[8]); n 936         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[7]);
952 937
953         if (unlikely(tmp_called_instance_1 == NULL)) { 938         if (unlikely(tmp_called_instance_1 == NULL)) {
t 954             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[8]); t 939             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[7]);
955         } 940         }
956 941
957         assert(!(tmp_called_instance_1 == NULL)); 942         assert(!(tmp_called_instance_1 == NULL));
958         frame_b8dd5304dbdcb75df56b24282c513cef->m_frame.f_lineno = 30; 943         frame_b8dd5304dbdcb75df56b24282c513cef->m_frame.f_lineno = 30;
959         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2( 944         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(