Construct ClosureVariableAccess

Performance Diagrams

Construct ClosureVariableAccess 001000000100000020000002000000300000030000004000000400000050000005000000600000060000007000000700000080000008000000CPython 3.10Nuitka (main)Nuitka (develop)Nuitka (factory)857331989.78846153846155257.0CPython 3.104750206244.59615384615387367.1965340870994Nuitka (main)4750499399.4038461538462367.18808872216056Nuitka (develop)4750130554.2115384615385367.1987246937047Nuitka (factory)Construct ClosureVariableAccessTicks Construct ClosureVariableAccess 001000000100000020000002000000300000030000004000000400000050000005000000600000060000007000000700000080000008000000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)842372989.78846153846155257.0CPython 3.84650234244.59615384615387367.6978475054493Nuitka (main)4649901399.4038461538462367.7076162697432Nuitka (develop)4650181554.2115384615385367.6994022937604Nuitka (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_b43d3e03bfffddc9629b68f0a7ec1a42; 83 static PyCodeObject *codeobj_b43d3e03bfffddc9629b68f0a7ec1a42;
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_635f23dce1bd7da3c01ad63d83548229 = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[15], mod_consts[15], NULL, NULL, 0, 0, 0); 89     codeobj_635f23dce1bd7da3c01ad63d83548229 = MAKE_CODE_OBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[15], mod_consts[15], NULL, NULL, 0, 0, 0);
90     codeobj_main = codeobj_635f23dce1bd7da3c01ad63d83548229; 90     codeobj_main = codeobj_635f23dce1bd7da3c01ad63d83548229;
91     codeobj_d4077f7d513b82edbcd5ffdf3c586389 = 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_d4077f7d513b82edbcd5ffdf3c586389 = 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_b43d3e03bfffddc9629b68f0a7ec1a42 = 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_b43d3e03bfffddc9629b68f0a7ec1a42 = 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);
888 873
889     // Module code. 874     // Module code.
890     { 875     {
891         PyObject *tmp_assign_source_1; 876         PyObject *tmp_assign_source_1;
892         tmp_assign_source_1 = Py_None; 877         tmp_assign_source_1 = Py_None;
n 893         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_1); n 878         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_1);
894     } 879     }
895     { 880     {
896         PyObject *tmp_assign_source_2; 881         PyObject *tmp_assign_source_2;
n 897         tmp_assign_source_2 = mod_consts[6]; n 882         tmp_assign_source_2 = mod_consts[5];
898         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_2); 883         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_2);
899     } 884     }
900     frame_635f23dce1bd7da3c01ad63d83548229 = MAKE_MODULE_FRAME(codeobj_635f23dce1bd7da3c01ad63d83548229, module___main__); 885     frame_635f23dce1bd7da3c01ad63d83548229 = MAKE_MODULE_FRAME(codeobj_635f23dce1bd7da3c01ad63d83548229, module___main__);
901 886
902     // Push the new frame as the currently active one, and we should be exclusively 887     // Push the new frame as the currently active one, and we should be exclusively
903     // owning it. 888     // owning it.
909         PyObject *tmp_assign_source_3; 894         PyObject *tmp_assign_source_3;
910         PyObject *tmp_name_value_1; 895         PyObject *tmp_name_value_1;
911         PyObject *tmp_globals_arg_value_1; 896         PyObject *tmp_globals_arg_value_1;
912         PyObject *tmp_locals_arg_value_1; 897         PyObject *tmp_locals_arg_value_1;
913         PyObject *tmp_fromlist_value_1; 898         PyObject *tmp_fromlist_value_1;
n 914         tmp_name_value_1 = mod_consts[8]; n 899         tmp_name_value_1 = mod_consts[7];
915         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__; 900         tmp_globals_arg_value_1 = (PyObject *)moduledict___main__;
916         tmp_locals_arg_value_1 = Py_None; 901         tmp_locals_arg_value_1 = Py_None;
917         tmp_fromlist_value_1 = Py_None; 902         tmp_fromlist_value_1 = Py_None;
918         frame_635f23dce1bd7da3c01ad63d83548229->m_frame.f_lineno = 4; 903         frame_635f23dce1bd7da3c01ad63d83548229->m_frame.f_lineno = 4;
919         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); 904         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);
925 910
926             exception_lineno = 4; 911             exception_lineno = 4;
927 912
928             goto frame_exception_exit_1; 913             goto frame_exception_exit_1;
929         } 914         }
n 930         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[8], tmp_assign_source_3); n 915         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_3);
931     } 916     }
932     { 917     {
933         PyObject *tmp_assign_source_4; 918         PyObject *tmp_assign_source_4;
n 934         tmp_assign_source_4 = mod_consts[9]; n 919         tmp_assign_source_4 = mod_consts[8];
935         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_4); 920         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_4);
936     } 921     }
937     { 922     {
938         PyObject *tmp_assign_source_5; 923         PyObject *tmp_assign_source_5;
939         tmp_assign_source_5 = Py_None; 924         tmp_assign_source_5 = Py_None;
n 940         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_5); n 925         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[9], tmp_assign_source_5);
941     } 926     }
942     { 927     {
943         PyObject *tmp_assign_source_6; 928         PyObject *tmp_assign_source_6;
944         tmp_assign_source_6 = Py_None; 929         tmp_assign_source_6 = Py_None;
n 945         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_6); n 930         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_6);
946     } 931     }
947     { 932     {
948         PyObject *tmp_assign_source_7; 933         PyObject *tmp_assign_source_7;
949 934
950 935
954     } 939     }
955     { 940     {
956         PyObject *tmp_assign_source_8; 941         PyObject *tmp_assign_source_8;
957         PyObject *tmp_iter_arg_1; 942         PyObject *tmp_iter_arg_1;
958         PyObject *tmp_called_instance_1; 943         PyObject *tmp_called_instance_1;
n 959         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[8]); n 944         tmp_called_instance_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[7]);
960 945
961         if (unlikely(tmp_called_instance_1 == NULL)) { 946         if (unlikely(tmp_called_instance_1 == NULL)) {
t 962             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[8]); t 947             tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[7]);
963         } 948         }
964 949
965         assert(!(tmp_called_instance_1 == NULL)); 950         assert(!(tmp_called_instance_1 == NULL));
966         frame_635f23dce1bd7da3c01ad63d83548229->m_frame.f_lineno = 30; 951         frame_635f23dce1bd7da3c01ad63d83548229->m_frame.f_lineno = 30;
967         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2( 952         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(