Construct BuiltinSumWithGenerator

Performance Diagrams

Construct BuiltinSumWithGenerator 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)16120717488.11538461538461257.0CPython 2.7115690341240.03846153846155326.7730095638872Nuitka (master)115690341391.96153846153845326.7730095638872Nuitka (develop)115690341543.8846153846154326.7730095638872Nuitka (factory)Construct BuiltinSumWithGeneratorTicks Construct BuiltinSumWithGenerator 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000240000000240000000CPython 3.8Nuitka (master)Nuitka (develop)Nuitka (factory)24520846388.11538461538461257.0CPython 3.8165087673240.03846153846155337.7438682756168Nuitka (master)165087654391.96153846153845337.7438874233748Nuitka (develop)165087654543.8846153846154337.7438874233748Nuitka (factory)Construct BuiltinSumWithGeneratorTicks

Source Code with Construct

empty = ()

def calledRepeatedly(iterable, empty):
    # Force frame
    itertools

    # We measure making a generator iterator step or not.

# construct_begin
    y = sum(iterable)
# construct_alternative



    return y

import itertools
for x in itertools.repeat(None, 500):
    calledRepeatedly((x for x in range(1000)), empty)

print("OK.")

Source Code without Construct

empty = ()

def calledRepeatedly(iterable, empty):
    # Force frame
    itertools

    # We measure making a generator iterator step or not.

# construct_begin

# construct_alternative
    y = sum(empty)
# construct_end

    return y

import itertools
for x in itertools.repeat(None, 500):
    calledRepeatedly((x for x in range(1000)), empty)

print("OK.")

Context Diff of Source Code


Construct
Baseline
25     itertools 25     itertools
26 26
27     # We measure making a generator iterator step or not. 27     # We measure making a generator iterator step or not.
28 28
29 # construct_begin 29 # construct_begin
n 30     y = sum(iterable) n 30  
31 # construct_alternative 31 # construct_alternative
t 32   t 32     y = sum(empty)
33   33 # construct_end
34 34
35     return y 35     return y
36 36
37 import itertools 37 import itertools
38 for x in itertools.repeat(None, 500): 38 for x in itertools.repeat(None, 500):

Context Diff of Generated Code


Construct
Baseline
172         } 172         }
173     } 173     }
174     { 174     {
175         PyObject *tmp_assign_source_1; 175         PyObject *tmp_assign_source_1;
176         PyObject *tmp_sum_sequence_1; 176         PyObject *tmp_sum_sequence_1;
n 177         CHECK_OBJECT(par_iterable); n 177         CHECK_OBJECT(par_empty);
178         tmp_sum_sequence_1 = par_iterable; 178         tmp_sum_sequence_1 = par_empty;
179         tmp_assign_source_1 = BUILTIN_SUM1(tmp_sum_sequence_1); 179         tmp_assign_source_1 = BUILTIN_SUM1(tmp_sum_sequence_1);
180         if (tmp_assign_source_1 == NULL) { 180         if (tmp_assign_source_1 == NULL) {
181             assert(ERROR_OCCURRED()); 181             assert(ERROR_OCCURRED());
182 182
183             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb); 183             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
184 184
185 185
t 186             exception_lineno = 30; t 186             exception_lineno = 32;
187             type_description_1 = "ooo"; 187             type_description_1 = "ooo";
188             goto frame_exception_exit_1; 188             goto frame_exception_exit_1;
189         } 189         }
190         assert(var_y == NULL); 190         assert(var_y == NULL);
191         var_y = tmp_assign_source_1; 191         var_y = tmp_assign_source_1;