Construct ClosureVariableAccess

Performance Diagrams

Construct ClosureVariableAccess 001000000100000020000002000000300000030000004000000400000050000005000000600000060000007000000700000080000008000000CPython 3.10Nuitka (main)Nuitka (develop)Nuitka (factory)857331989.78846153846155257.0CPython 3.104750209244.59615384615387367.19644761578604Nuitka (main)4750174399.4038461538462367.1974564477754Nuitka (develop)4750059554.2115384615385367.20077118145446Nuitka (factory)Construct ClosureVariableAccessTicks Construct ClosureVariableAccess 001000000100000020000002000000300000030000004000000400000050000005000000600000060000007000000700000080000008000000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)842372989.78846153846155257.0CPython 3.84650380244.59615384615387367.6935645036868Nuitka (main)4650059399.4038461538462367.7029812404386Nuitka (develop)4650338554.2115384615385367.69479660008426Nuitka (factory)Construct ClosureVariableAccessTicks Construct ClosureVariableAccess 0010000001000000200000020000003000000300000040000004000000500000050000006000000600000070000007000000CPython 2.7Nuitka (main)Nuitka (develop)Nuitka (factory)724436489.78846153846155257.0CPython 2.73000096244.59615384615387401.777915525886Nuitka (main)3000096399.4038461538462401.777915525886Nuitka (develop)3000096554.2115384615385401.777915525886Nuitka (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_30f80b7d6bf0ad4c68879c385892b24b; 83 static PyCodeObject *codeobj_30f80b7d6bf0ad4c68879c385892b24b;
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_69c93ec43d01e491799582f84eff0b88 = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[15], mod_consts[15], NULL, NULL, 0, 0, 0); 89     codeobj_69c93ec43d01e491799582f84eff0b88 = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[15], mod_consts[15], NULL, NULL, 0, 0, 0);
90     codeobj_main = codeobj_69c93ec43d01e491799582f84eff0b88; 90     codeobj_main = codeobj_69c93ec43d01e491799582f84eff0b88;
91     codeobj_9291ec330791f784fe219bbe6f416efe = 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_9291ec330791f784fe219bbe6f416efe = 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_30f80b7d6bf0ad4c68879c385892b24b = MAKE_CODE_OBJECT(module_filename_obj, 14, CO_OPTIMIZED | CO_NEWLOCALS, mod_consts[1], mod_consts[1], mod_consts[17], mod_consts[17], 0, 0, 0); 92     codeobj_30f80b7d6bf0ad4c68879c385892b24b = MAKE_CODE_OBJECT(module_filename_obj, 14, CO_OPTIMIZED | CO_NEWLOCALS, mod_consts[1], mod_consts[1], mod_consts[17], mod_consts[17], 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);
885 870
886     // Module code. 871     // Module code.
887     { 872     {
888         PyObject *tmp_assign_source_1; 873         PyObject *tmp_assign_source_1;
889         tmp_assign_source_1 = Py_None; 874         tmp_assign_source_1 = Py_None;
n 890         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_1); n 875         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_1);
891     } 876     }
892     { 877     {
893         PyObject *tmp_assign_source_2; 878         PyObject *tmp_assign_source_2;
n 894         tmp_assign_source_2 = mod_consts[6]; n 879         tmp_assign_source_2 = mod_consts[5];
895         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_2); 880         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_2);
896     } 881     }
897     frame_69c93ec43d01e491799582f84eff0b88 = MAKE_MODULE_FRAME(codeobj_69c93ec43d01e491799582f84eff0b88, module___main__); 882     frame_69c93ec43d01e491799582f84eff0b88 = MAKE_MODULE_FRAME(codeobj_69c93ec43d01e491799582f84eff0b88, module___main__);
898 883
899     // Push the new frame as the currently active one, and we should be exclusively 884     // Push the new frame as the currently active one, and we should be exclusively
900     // owning it. 885     // owning it.
906         PyObject *tmp_assign_source_3; 891         PyObject *tmp_assign_source_3;
907         PyObject *tmp_name_value_1; 892         PyObject *tmp_name_value_1;
908         PyObject *tmp_globals_arg_value_1; 893         PyObject *tmp_globals_arg_value_1;
909         PyObject *tmp_locals_arg_value_1; 894         PyObject *tmp_locals_arg_value_1;
910         PyObject *tmp_fromlist_value_1; 895         PyObject *tmp_fromlist_value_1;
n 911         tmp_name_value_1 = mod_consts[8]; n 896         tmp_name_value_1 = mod_consts[7];
912         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__; 897         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__;
913         tmp_locals_arg_value_1 = Py_None; 898         tmp_locals_arg_value_1 = Py_None;
914         tmp_fromlist_value_1 = Py_None; 899         tmp_fromlist_value_1 = Py_None;
915         frame_69c93ec43d01e491799582f84eff0b88->m_frame.f_lineno = 4; 900         frame_69c93ec43d01e491799582f84eff0b88->m_frame.f_lineno = 4;
916         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); 901         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);
922 907
923             exception_lineno = 4; 908             exception_lineno = 4;
924 909
925             goto frame_exception_exit_1; 910             goto frame_exception_exit_1;
926         } 911         }
n 927         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[8], tmp_assign_source_3); n 912         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_3);
928     } 913     }
929     { 914     {
930         PyObject *tmp_assign_source_4; 915         PyObject *tmp_assign_source_4;
n 931         tmp_assign_source_4 = mod_consts[9]; n 916         tmp_assign_source_4 = mod_consts[8];
932         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_4); 917         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_4);
933     } 918     }
934     { 919     {
935         PyObject *tmp_assign_source_5; 920         PyObject *tmp_assign_source_5;
936         tmp_assign_source_5 = Py_None; 921         tmp_assign_source_5 = Py_None;
n 937         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_5); n 922         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[9], tmp_assign_source_5);
938     } 923     }
939     { 924     {
940         PyObject *tmp_assign_source_6; 925         PyObject *tmp_assign_source_6;
941         tmp_assign_source_6 = Py_None; 926         tmp_assign_source_6 = Py_None;
n 942         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_6); n 927         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_6);
943     } 928     }
944     { 929     {
945         PyObject *tmp_assign_source_7; 930         PyObject *tmp_assign_source_7;
946 931
947 932
951     } 936     }
952     { 937     {
953         PyObject *tmp_assign_source_8; 938         PyObject *tmp_assign_source_8;
954         PyObject *tmp_iter_arg_1; 939         PyObject *tmp_iter_arg_1;
955         PyObject *tmp_called_instance_1; 940         PyObject *tmp_called_instance_1;
n 956         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[8]); n 941         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[7]);
957 942
958         if (unlikely(tmp_called_instance_1 == NULL)) { 943         if (unlikely(tmp_called_instance_1 == NULL)) {
t 959             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[8]); t 944             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[7]);
960         } 945         }
961 946
962         assert(!(tmp_called_instance_1 == NULL)); 947         assert(!(tmp_called_instance_1 == NULL));
963         frame_69c93ec43d01e491799582f84eff0b88->m_frame.f_lineno = 30; 948         frame_69c93ec43d01e491799582f84eff0b88->m_frame.f_lineno = 30;
964         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2( 949         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(