Construct FunctionCreationLocal

Performance Diagrams

Construct FunctionCreationLocal 00200000020000004000000400000060000006000000800000080000001000000010000000120000001200000014000000140000001600000016000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)1717225788.95192307692307257.0CPython 2.77850310242.31730769230768391.1464036014154Nuitka (master)7950321395.6826923076923389.70720683591344Nuitka (develop)7949728549.0480769230769389.71574033404806Nuitka (factory)Construct FunctionCreationLocalTicks Construct FunctionCreationLocal 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)2502587188.95192307692307257.0CPython 3.59300800242.31730769230768412.27559333576164Nuitka (master)9600671395.6826923076923409.3145480438715Nuitka (develop)9600931549.0480769230769409.31198070066097Nuitka (factory)Construct FunctionCreationLocalTicks

Source Code with Construct

def calledRepeatedly():
    # We measure making a local function that will remain unused.
# construct_begin
    def empty():
        pass
# construct_alternative



    return empty


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

print("OK.")

Source Code without Construct

def calledRepeatedly():
    # We measure making a local function that will remain unused.
# construct_begin


# construct_alternative
    empty = 1
# construct_end

    return empty


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

print("OK.")

Context Diff of Source Code


Construct
Baseline
21 21
22 22
23 def calledRepeatedly(): 23 def calledRepeatedly():
24     # We measure making a local function that will remain unused. 24     # We measure making a local function that will remain unused.
25 # construct_begin 25 # construct_begin
n 26     def empty(): n
27         pass
28 # construct_alternative
29 26
30 27
t t 28 # construct_alternative
29     empty = 1
30 # construct_end
31 31
32     return empty 32     return empty
33 33
34 34
35 import itertools 35 import itertools

Context Diff of Generated Code


Construct
Baseline
30 PyObject *module___main__; 30 PyObject *module___main__;
31 PyDictObject *moduledict___main__; 31 PyDictObject *moduledict___main__;
32 32
33 /* The declarations of module constants used, if any. */ 33 /* The declarations of module constants used, if any. */
34 extern PyObject *const_str_plain___file__; 34 extern PyObject *const_str_plain___file__;
n n 35 static PyObject *const_str_plain_repeat;
35 static PyObject *const_tuple_none_int_pos_50000_tuple; 36 static PyObject *const_tuple_none_int_pos_50000_tuple;
36 static PyObject *const_str_plain_itertools; 37 static PyObject *const_str_plain_itertools;
37 static PyObject *const_str_plain_calledRepeatedly; 38 static PyObject *const_str_plain_calledRepeatedly;
38 extern PyObject *const_int_0; 39 extern PyObject *const_int_0;
39 static PyObject *const_str_angle_module; 40 static PyObject *const_str_angle_module;
40 static PyObject *const_tuple_str_plain_empty_tuple; 41 static PyObject *const_tuple_str_plain_empty_tuple;
41 static PyObject *const_str_plain_None; 42 static PyObject *const_str_plain_None;
42 static PyObject *const_str_plain_x; 43 static PyObject *const_str_plain_x;
43 static PyObject *const_str_digest_be086a4aaee4f94d2b996784c24bf2b4; 44 static PyObject *const_str_digest_be086a4aaee4f94d2b996784c24bf2b4;
n 44 static PyObject *const_str_plain_empty; n 45 extern PyObject *const_str_plain_print;
45 static PyObject *const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd; 46 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
46 extern PyObject *const_str_plain___doc__; 47 extern PyObject *const_str_plain___doc__;
47 extern PyObject *const_str_plain___cached__; 48 extern PyObject *const_str_plain___cached__;
n 48 extern PyObject *const_str_plain_print; n
49 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
50 static PyObject *const_str_plain_repeat;
51 extern PyObject *const_tuple_empty; 49 extern PyObject *const_tuple_empty;
n n 50 static PyObject *const_str_plain_empty;
51 extern PyObject *const_int_pos_1;
52 static PyObject *const_int_pos_50000; 52 static PyObject *const_int_pos_50000;
53 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352; 53 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352;
54 static PyObject *module_filename_obj; 54 static PyObject *module_filename_obj;
55 55
56 /* Indicator if this modules private constants were created yet. */ 56 /* Indicator if this modules private constants were created yet. */
57 static bool constants_created = false; 57 static bool constants_created = false;
58 58
59 /* Function to create module private constants. */ 59 /* Function to create module private constants. */
60 static void createModuleConstants( void ) 60 static void createModuleConstants( void )
61 { 61 {
n n 62     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 38 ], 6, 1 );
62     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 63     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
63     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF(Py_None); 64     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF(Py_None);
64     const_int_pos_50000 = PyLong_FromUnsignedLong(50000ul); 65     const_int_pos_50000 = PyLong_FromUnsignedLong(50000ul);
65     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF(const_int_pos_50000); 66     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF(const_int_pos_50000);
n 66     const_str_plain_itertools = UNSTREAM_STRING_ASCII( &constant_bin[ 38 ], 9, 1 ); n 67     const_str_plain_itertools = UNSTREAM_STRING_ASCII( &constant_bin[ 44 ], 9, 1 );
67     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 6 ], 16, 1 ); 68     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII( &constant_bin[ 6 ], 16, 1 );
n 68     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 47 ], 8, 0 ); n 69     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 53 ], 8, 0 );
69     const_tuple_str_plain_empty_tuple = PyTuple_New( 1 ); 70     const_tuple_str_plain_empty_tuple = PyTuple_New( 1 );
n 70     const_str_plain_empty = UNSTREAM_STRING_ASCII( &constant_bin[ 55 ], 5, 1 ); n 71     const_str_plain_empty = UNSTREAM_STRING_ASCII( &constant_bin[ 61 ], 5, 1 );
71     PyTuple_SET_ITEM( const_tuple_str_plain_empty_tuple, 0, const_str_plain_empty ); Py_INCREF(const_str_plain_empty); 72     PyTuple_SET_ITEM( const_tuple_str_plain_empty_tuple, 0, const_str_plain_empty ); Py_INCREF(const_str_plain_empty);
n 72     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 60 ], 4, 1 ); n 73     const_str_plain_None = UNSTREAM_STRING_ASCII( &constant_bin[ 66 ], 4, 1 );
73     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 64 ], 1, 1 ); 74     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 70 ], 1, 1 );
74     const_str_digest_be086a4aaee4f94d2b996784c24bf2b4 = UNSTREAM_STRING_ASCII( &constant_bin[ 65 ], 46, 0 ); 75     const_str_digest_be086a4aaee4f94d2b996784c24bf2b4 = UNSTREAM_STRING_ASCII( &constant_bin[ 71 ], 46, 0 );
75     const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd = UNSTREAM_STRING_ASCII( &constant_bin[ 111 ], 31, 0 );
76     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 76     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 77     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 142 ], 3, 0 ); n 77     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 117 ], 3, 0 );
78     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF(const_str_digest_5ed1392909ad16e6227b8230f4582352); 78     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF(const_str_digest_5ed1392909ad16e6227b8230f4582352);
n 79     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 145 ], 6, 1 ); n
80 79
81     constants_created = true; 80     constants_created = true;
82 } 81 }
83 82
84 /* Function to verify module private constants for non-corruption. */ 83 /* Function to verify module private constants for non-corruption. */
93 #endif 92 #endif
94 93
95 // The module code objects. 94 // The module code objects.
96 static PyCodeObject *codeobj_af6bd3e574802145a18df54cb6527ac8; 95 static PyCodeObject *codeobj_af6bd3e574802145a18df54cb6527ac8;
97 static PyCodeObject *codeobj_47aae6469e9cef21668d4e0370c680ad; 96 static PyCodeObject *codeobj_47aae6469e9cef21668d4e0370c680ad;
n 98 static PyCodeObject *codeobj_3665ff3352a9413e484b48b22d044692; n
99 /* For use in "MainProgram.c". */ 97 /* For use in "MainProgram.c". */
100 PyCodeObject *codeobj_main = NULL; 98 PyCodeObject *codeobj_main = NULL;
101 99
102 static void createModuleCodeObjects(void) 100 static void createModuleCodeObjects(void)
103 { 101 {
104     module_filename_obj = const_str_digest_be086a4aaee4f94d2b996784c24bf2b4; 102     module_filename_obj = const_str_digest_be086a4aaee4f94d2b996784c24bf2b4;
105     codeobj_af6bd3e574802145a18df54cb6527ac8 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE ); 103     codeobj_af6bd3e574802145a18df54cb6527ac8 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE );
106     codeobj_47aae6469e9cef21668d4e0370c680ad = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 23, const_tuple_str_plain_empty_tuple, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE ); 104     codeobj_47aae6469e9cef21668d4e0370c680ad = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 23, const_tuple_str_plain_empty_tuple, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE );
n 107     codeobj_3665ff3352a9413e484b48b22d044692 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_empty, 26, const_tuple_empty, 0, 0, CO_NOFREE ); n
108 } 105 }
109 106
110 // The module function declarations. 107 // The module function declarations.
111 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ); 108 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  );
n 112   n
113  
114 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  );
115 109
116 110
117 // The module function definitions. 111 // The module function definitions.
118 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars ) 112 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
119 { 113 {
121 #ifndef __NUITKA_NO_ASSERT__ 115 #ifndef __NUITKA_NO_ASSERT__
122     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 116     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
123 #endif 117 #endif
124 118
125     // Local variable declarations. 119     // Local variable declarations.
n 126     PyObject *var_empty = NULL; n
127     PyObject *tmp_return_value = NULL; 120     PyObject *tmp_return_value = NULL;
128 121
129     // Actual function body. 122     // Actual function body.
n 130     { n 123     tmp_return_value = const_int_pos_1;
131         PyObject *tmp_assign_source_1;
132         tmp_assign_source_1 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  );
133  
134  
135  
136         assert(var_empty == NULL);
137         var_empty = tmp_assign_source_1;
138     }
139     // Tried code:
140     CHECK_OBJECT(var_empty);
141     tmp_return_value = var_empty;
142     Py_INCREF(tmp_return_value); 124     Py_INCREF(tmp_return_value);
n 143     goto try_return_handler_1; n
144     // tried codes exits in all cases
145     NUITKA_CANNOT_GET_HERE(__main__$$$function_1_calledRepeatedly);
146     return NULL;
147     // Return handler code:
148     try_return_handler_1:;
149     CHECK_OBJECT((PyObject *)var_empty);
150     Py_DECREF(var_empty);
151     var_empty = NULL;
152  
153     goto function_return_exit; 125     goto function_return_exit;
n 154     // End of try: n
155 126
156     // Return statement must have exited already. 127     // Return statement must have exited already.
157     NUITKA_CANNOT_GET_HERE(__main__$$$function_1_calledRepeatedly); 128     NUITKA_CANNOT_GET_HERE(__main__$$$function_1_calledRepeatedly);
158     return NULL; 129     return NULL;
159 130
178         const_str_plain_calledRepeatedly, 149         const_str_plain_calledRepeatedly,
179 #if PYTHON_VERSION >= 300 150 #if PYTHON_VERSION >= 300
180         NULL, 151         NULL,
181 #endif 152 #endif
182         codeobj_47aae6469e9cef21668d4e0370c680ad, 153         codeobj_47aae6469e9cef21668d4e0370c680ad,
t 183         NULL, t
184 #if PYTHON_VERSION >= 300
185         NULL,
186         NULL,
187 #endif
188         module___main__,
189         NULL,
190         0
191     );
192  
193     return (PyObject *)result;
194 }
195  
196  
197  
198 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  )
199 {
200     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
201         NULL,
202         const_str_plain_empty,
203 #if PYTHON_VERSION >= 300
204         const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd,
205 #endif
206         codeobj_3665ff3352a9413e484b48b22d044692,
207         NULL, 154         NULL,
208 #if PYTHON_VERSION >= 300 155 #if PYTHON_VERSION >= 300
209         NULL, 156         NULL,
210         NULL, 157         NULL,
211 #endif 158 #endif