Construct NumpyArrayConstruction

Performance Diagrams

Construct NumpyArrayConstruction 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)21029432188.11538461538461260.0851751854218CPython 2.7212939594240.03846153846155257.01554153521295Nuitka (master)212941070391.96153846153845257.01382875196987Nuitka (develop)212952987543.8846153846154257.0Nuitka (factory)Construct NumpyArrayConstructionTicks Construct NumpyArrayConstruction 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000240000000240000000260000000260000000280000000280000000CPython 3.8Nuitka (master)Nuitka (develop)Nuitka (factory)29109406988.11538461538461263.93625870564256CPython 3.8299500291240.03846153846155257.0003597397201Nuitka (master)299500727391.96153846153845257.00000000000006Nuitka (develop)299500238543.8846153846154257.0004034695485Nuitka (factory)Construct NumpyArrayConstructionTicks

Source Code with Construct

from __future__ import print_function

# nuitka-project: --nofollow-import-to=numpy
import numpy


g = 6

def calledRepeatedly():
    y = numpy.array([[1, 2, 3], [4, 5, 6]], numpy.int32)
    # This is supposed to make a call to a compiled function, which is
    # being optimized separately.
# construct_begin
    x = numpy.array([[1, 2, 3], [4, 5, 6]], numpy.int32)
# construct_alternative



    return x, y

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

print("OK.")

Source Code without Construct

from __future__ import print_function

# nuitka-project: --nofollow-import-to=numpy
import numpy


g = 6

def calledRepeatedly():
    y = numpy.array([[1, 2, 3], [4, 5, 6]], numpy.int32)
    # This is supposed to make a call to a compiled function, which is
    # being optimized separately.
# construct_begin

# construct_alternative
    x = g
# construct_end

    return x, y

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

print("OK.")

Context Diff of Source Code


Construct
Baseline
28 def calledRepeatedly(): 28 def calledRepeatedly():
29     y = numpy.array([[1, 2, 3], [4, 5, 6]], numpy.int32) 29     y = numpy.array([[1, 2, 3], [4, 5, 6]], numpy.int32)
30     # This is supposed to make a call to a compiled function, which is 30     # This is supposed to make a call to a compiled function, which is
31     # being optimized separately. 31     # being optimized separately.
32 # construct_begin 32 # construct_begin
n 33     x = numpy.array([[1, 2, 3], [4, 5, 6]], numpy.int32) n 33  
34 # construct_alternative 34 # construct_alternative
t 35   t 35     x = g
36   36 # construct_end
37 37
38     return x, y 38     return x, y
39 39
40 import itertools 40 import itertools
41 for x in itertools.repeat(None, 20000): 41 for x in itertools.repeat(None, 20000):

Context Diff of Generated Code


Construct
Baseline
82 static PyCodeObject *codeobj_1804c904ec6070f57b4ad6bfc1cee340; 82 static PyCodeObject *codeobj_1804c904ec6070f57b4ad6bfc1cee340;
83 /* For use in "MainProgram.c". */ 83 /* For use in "MainProgram.c". */
84 PyCodeObject *codeobj_main = NULL; 84 PyCodeObject *codeobj_main = NULL;
85 85
86 static void createModuleCodeObjects(void) { 86 static void createModuleCodeObjects(void) {
n 87     module_filename_obj = mod_consts[5]; CHECK_OBJECT(module_filename_obj); n 87     module_filename_obj = mod_consts[6]; CHECK_OBJECT(module_filename_obj);
88     codeobj_7bc0a2614bf747924dd36dc7ae5d4f05 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[20], NULL, NULL, 0, 0, 0); 88     codeobj_7bc0a2614bf747924dd36dc7ae5d4f05 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[20], NULL, NULL, 0, 0, 0);
89     codeobj_1804c904ec6070f57b4ad6bfc1cee340 = MAKE_CODEOBJECT(module_filename_obj, 28, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[13], mod_consts[21], NULL, 0, 0, 0); 89     codeobj_1804c904ec6070f57b4ad6bfc1cee340 = MAKE_CODEOBJECT(module_filename_obj, 28, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[13], mod_consts[21], NULL, 0, 0, 0);
90 } 90 }
91 91
92 // The module function declarations. 92 // The module function declarations.
231         assert(var_y == NULL); 231         assert(var_y == NULL);
232         var_y = tmp_assign_source_1; 232         var_y = tmp_assign_source_1;
233     } 233     }
234     { 234     {
235         PyObject *tmp_assign_source_2; 235         PyObject *tmp_assign_source_2;
n 236         PyObject *tmp_called_name_2; n
237         PyObject *tmp_expression_name_3;
238         PyObject *tmp_args_element_name_3;
239         PyObject *tmp_args_element_name_4;
240         PyObject *tmp_expression_name_4;
241         tmp_expression_name_3 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[0]); 236         tmp_assign_source_2 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[4]);
242 237
n 243         if (unlikely(tmp_expression_name_3 == NULL)) { n 238         if (unlikely(tmp_assign_source_2 == NULL)) {
244             tmp_expression_name_3 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[0]); 239             tmp_assign_source_2 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[4]);
245         } 240         }
246 241
n 247         if (tmp_expression_name_3 == NULL) { n 242         if (tmp_assign_source_2 == NULL) {
248             assert(ERROR_OCCURRED()); 243             assert(ERROR_OCCURRED());
249 244
250             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb); 245             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
251 246
252 247
n 253             exception_lineno = 33; n 248             exception_lineno = 35;
254             type_description_1 = "oo"; 249             type_description_1 = "oo";
255             goto frame_exception_exit_1; 250             goto frame_exception_exit_1;
256         } 251         }
n 257         tmp_called_name_2 = LOOKUP_ATTRIBUTE(tmp_expression_name_3, mod_consts[1]); n
258         if (tmp_called_name_2 == NULL) {
259             assert(ERROR_OCCURRED());
260  
261             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
262  
263  
264             exception_lineno = 33;
265             type_description_1 = "oo";
266             goto frame_exception_exit_1;
267         }
268         tmp_args_element_name_3 = DEEP_COPY_LIST(mod_consts[2]);
269         tmp_expression_name_4 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[0]);
270  
271         if (unlikely(tmp_expression_name_4 == NULL)) {
272             tmp_expression_name_4 = GET_MODULE_VARIABLE_VALUE_FALLBACK(mod_consts[0]);
273         }
274  
275         if (tmp_expression_name_4 == NULL) {
276             assert(ERROR_OCCURRED());
277  
278             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
279             Py_DECREF(tmp_called_name_2);
280             Py_DECREF(tmp_args_element_name_3);
281  
282             exception_lineno = 33;
283             type_description_1 = "oo";
284             goto frame_exception_exit_1;
285         }
286         tmp_args_element_name_4 = LOOKUP_ATTRIBUTE(tmp_expression_name_4, mod_consts[3]);
287         if (tmp_args_element_name_4 == NULL) {
288             assert(ERROR_OCCURRED());
289  
290             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
291             Py_DECREF(tmp_called_name_2);
292             Py_DECREF(tmp_args_element_name_3);
293  
294             exception_lineno = 33;
295             type_description_1 = "oo";
296             goto frame_exception_exit_1;
297         }
298         frame_1804c904ec6070f57b4ad6bfc1cee340->m_frame.f_lineno = 33;
299         {
300             PyObject *call_args[] = {tmp_args_element_name_3, tmp_args_element_name_4};
301             tmp_assign_source_2 = CALL_FUNCTION_WITH_ARGS2(tmp_called_name_2, call_args);
302         }
303  
304         Py_DECREF(tmp_called_name_2);
305         Py_DECREF(tmp_args_element_name_3);
306         Py_DECREF(tmp_args_element_name_4);
307         if (tmp_assign_source_2 == NULL) {
308             assert(ERROR_OCCURRED());
309  
310             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
311  
312  
313             exception_lineno = 33;
314             type_description_1 = "oo";
315             goto frame_exception_exit_1;
316         }
317         assert(var_x == NULL); 252         assert(var_x == NULL);
n n 253         Py_INCREF(tmp_assign_source_2);
318         var_x = tmp_assign_source_2; 254         var_x = tmp_assign_source_2;
319     } 255     }
320 256
321 #if 0 257 #if 0
322     RESTORE_FRAME_EXCEPTION(frame_1804c904ec6070f57b4ad6bfc1cee340); 258     RESTORE_FRAME_EXCEPTION(frame_1804c904ec6070f57b4ad6bfc1cee340);
839         } 775         }
840     } 776     }
841     { 777     {
842         PyObject *tmp_assign_source_1; 778         PyObject *tmp_assign_source_1;
843         tmp_assign_source_1 = Py_None; 779         tmp_assign_source_1 = Py_None;
n 844         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_1); n 780         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_1);
845     } 781     }
846     { 782     {
847         PyObject *tmp_assign_source_2; 783         PyObject *tmp_assign_source_2;
n 848         tmp_assign_source_2 = mod_consts[5]; n 784         tmp_assign_source_2 = mod_consts[6];
849         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_2); 785         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_2);
850     } 786     }
851     { 787     {
852         PyObject *tmp_assign_source_3; 788         PyObject *tmp_assign_source_3;
853         tmp_assign_source_3 = Py_None; 789         tmp_assign_source_3 = Py_None;
n 854         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_3); n 790         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[8], tmp_assign_source_3);
855     } 791     }
856     { 792     {
857         PyObject *tmp_assign_source_4; 793         PyObject *tmp_assign_source_4;
858         tmp_assign_source_4 = PyDict_New(); 794         tmp_assign_source_4 = PyDict_New();
n 859         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[8], tmp_assign_source_4); n 795         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[9], tmp_assign_source_4);
860     } 796     }
861     { 797     {
862         PyObject *tmp_assign_source_5; 798         PyObject *tmp_assign_source_5;
863         frame_7bc0a2614bf747924dd36dc7ae5d4f05->m_frame.f_lineno = 20; 799         frame_7bc0a2614bf747924dd36dc7ae5d4f05->m_frame.f_lineno = 20;
864         { 800         {
865             PyObject *hard_module = IMPORT_HARD___FUTURE__(); 801             PyObject *hard_module = IMPORT_HARD___FUTURE__();
n 866             tmp_assign_source_5 = LOOKUP_ATTRIBUTE(hard_module, mod_consts[9]); n 802             tmp_assign_source_5 = LOOKUP_ATTRIBUTE(hard_module, mod_consts[10]);
867         } 803         }
868 804
869         assert(!(tmp_assign_source_5 == NULL)); 805         assert(!(tmp_assign_source_5 == NULL));
n 870         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[9], tmp_assign_source_5); n 806         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[10], tmp_assign_source_5);
871     } 807     }
872     { 808     {
873         PyObject *tmp_assign_source_6; 809         PyObject *tmp_assign_source_6;
874         PyObject *tmp_name_name_1; 810         PyObject *tmp_name_name_1;
875         PyObject *tmp_globals_arg_name_1; 811         PyObject *tmp_globals_arg_name_1;
878         PyObject *tmp_level_name_1; 814         PyObject *tmp_level_name_1;
879         tmp_name_name_1 = mod_consts[0]; 815         tmp_name_name_1 = mod_consts[0];
880         tmp_globals_arg_name_1 = (PyObject *)moduledict___main__; 816         tmp_globals_arg_name_1 = (PyObject *)moduledict___main__;
881         tmp_locals_arg_name_1 = Py_None; 817         tmp_locals_arg_name_1 = Py_None;
882         tmp_fromlist_name_1 = Py_None; 818         tmp_fromlist_name_1 = Py_None;
n 883         tmp_level_name_1 = mod_consts[10]; n 819         tmp_level_name_1 = mod_consts[11];
884         frame_7bc0a2614bf747924dd36dc7ae5d4f05->m_frame.f_lineno = 23; 820         frame_7bc0a2614bf747924dd36dc7ae5d4f05->m_frame.f_lineno = 23;
885         tmp_assign_source_6 = IMPORT_MODULE5(tmp_name_name_1, tmp_globals_arg_name_1, tmp_locals_arg_name_1, tmp_fromlist_name_1, tmp_level_name_1); 821         tmp_assign_source_6 = IMPORT_MODULE5(tmp_name_name_1, tmp_globals_arg_name_1, tmp_locals_arg_name_1, tmp_fromlist_name_1, tmp_level_name_1);
886         if (tmp_assign_source_6 == NULL) { 822         if (tmp_assign_source_6 == NULL) {
887             assert(ERROR_OCCURRED()); 823             assert(ERROR_OCCURRED());
888 824
895         } 831         }
896         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_6); 832         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_6);
897     } 833     }
898     { 834     {
899         PyObject *tmp_assign_source_7; 835         PyObject *tmp_assign_source_7;
n 900         tmp_assign_source_7 = mod_consts[11]; n 836         tmp_assign_source_7 = mod_consts[12];
901         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[12], tmp_assign_source_7); 837         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_7);
902     } 838     }
903     { 839     {
904         PyObject *tmp_assign_source_8; 840         PyObject *tmp_assign_source_8;
905 841
906 842
917         PyObject *tmp_level_name_2; 853         PyObject *tmp_level_name_2;
918         tmp_name_name_2 = mod_consts[14]; 854         tmp_name_name_2 = mod_consts[14];
919         tmp_globals_arg_name_2 = (PyObject *)moduledict___main__; 855         tmp_globals_arg_name_2 = (PyObject *)moduledict___main__;
920         tmp_locals_arg_name_2 = Py_None; 856         tmp_locals_arg_name_2 = Py_None;
921         tmp_fromlist_name_2 = Py_None; 857         tmp_fromlist_name_2 = Py_None;
t 922         tmp_level_name_2 = mod_consts[10]; t 858         tmp_level_name_2 = mod_consts[11];
923         frame_7bc0a2614bf747924dd36dc7ae5d4f05->m_frame.f_lineno = 40; 859         frame_7bc0a2614bf747924dd36dc7ae5d4f05->m_frame.f_lineno = 40;
924         tmp_assign_source_9 = IMPORT_MODULE5(tmp_name_name_2, tmp_globals_arg_name_2, tmp_locals_arg_name_2, tmp_fromlist_name_2, tmp_level_name_2); 860         tmp_assign_source_9 = IMPORT_MODULE5(tmp_name_name_2, tmp_globals_arg_name_2, tmp_locals_arg_name_2, tmp_fromlist_name_2, tmp_level_name_2);
925         assert(!(tmp_assign_source_9 == NULL)); 861         assert(!(tmp_assign_source_9 == NULL));
926         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[14], tmp_assign_source_9); 862         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[14], tmp_assign_source_9);
927     } 863     }