.. title: Construct RichComparisonConditionStrings .. tags: 310_develop_steady_vs_main,310_factory_steady_vs_develop,38_develop_steady_vs_main,38_factory_steady_vs_develop,27_develop_steady_vs_main,27_factory_steady_vs_develop .. date: 03/28/2024, 10:20:18 .. contents:: Performance Diagrams ==================== .. chart:: Bar :title: 'Construct RichComparisonConditionStrings' :x_labels: ['CPython 3.10', 'Nuitka (main)', 'Nuitka (develop)', 'Nuitka (factory)'] 'Ticks', [14538487, 6450043, 6449860, 6449967] .. chart:: Bar :title: 'Construct RichComparisonConditionStrings' :x_labels: ['CPython 3.8', 'Nuitka (main)', 'Nuitka (develop)', 'Nuitka (factory)'] 'Ticks', [15512050, 6524735, 6524498, 6524996] .. chart:: Bar :title: 'Construct RichComparisonConditionStrings' :x_labels: ['CPython 2.7', 'Nuitka (main)', 'Nuitka (develop)', 'Nuitka (factory)'] 'Ticks', [12309150, 2749742, 2749738, 2749742] Source Code with Construct ========================== .. code-block:: python y = not y 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 ============================= .. code-block:: python if y: # construct_end y = not y 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 =========================== .. raw:: html
Construct | Baseline | ||||
---|---|---|---|---|---|
13 | for _x in itertools.repeat(None, loop_count): | 13 | for _x in itertools.repeat(None, loop_count): | ||
14 | x += 1 | 14 | x += 1 | ||
15 | y = x % 2 == 0 | 15 | y = x % 2 == 0 | ||
16 | 16 | ||||
17 | # construct_begin | 17 | # construct_begin | ||
n | 18 | if x % 2 == 0: | n | 18 | |
19 | # construct_alternative | 19 | # construct_alternative | ||
t | 20 | t | 20 | if y: | |
21 | 21 | # construct_end | |||
22 | y = not y | 22 | y = not y | ||
23 | 23 | ||||
24 | print("OK.") | 24 | print("OK.") | ||
25 | 25 | ||||
26 | # Python test originally created or extracted from other peoples work. The | 26 | # Python test originally created or extracted from other peoples work. The |
Construct | Baseline | ||||
---|---|---|---|---|---|
819 | } | 819 | } | ||
820 | UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[18], tmp_assign_source_13); | 820 | UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[18], tmp_assign_source_13); | ||
821 | } | 821 | } | ||
822 | { | 822 | { | ||
823 | nuitka_bool tmp_condition_result_2; | 823 | nuitka_bool tmp_condition_result_2; | ||
n | 824 | PyObject *tmp_cmp_expr_left_3; | n | 824 | PyObject *tmp_mvar_value_1; |
825 | PyObject *tmp_cmp_expr_right_3; | 825 | int tmp_truth_name_1; | ||
826 | PyObject *tmp_mod_expr_left_2; | ||||
827 | PyObject *tmp_mod_expr_right_2; | ||||
828 | tmp_mod_expr_left_2 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[15]); | 826 | tmp_mvar_value_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[18]); | ||
829 | 827 | ||||
n | 830 | if (unlikely(tmp_mod_expr_left_2 == NULL)) { | n | 828 | if (unlikely(tmp_mvar_value_1 == NULL)) { |
831 | tmp_mod_expr_left_2 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[15]); | 829 | tmp_mvar_value_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[18]); | ||
832 | } | 830 | } | ||
833 | 831 | ||||
n | 834 | if (tmp_mod_expr_left_2 == NULL) { | n | 832 | assert(!(tmp_mvar_value_1 == NULL)); |
833 | tmp_truth_name_1 = CHECK_IF_TRUE(tmp_mvar_value_1); | ||||
834 | if (tmp_truth_name_1 == -1) { | ||||
835 | assert(HAS_ERROR_OCCURRED(tstate)); | 835 | assert(HAS_ERROR_OCCURRED(tstate)); | ||
836 | 836 | ||||
837 | FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb); | 837 | FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb); | ||
838 | 838 | ||||
839 | 839 | ||||
n | 840 | exception_lineno = 18; | n | 840 | exception_lineno = 20; |
841 | 841 | ||||
842 | goto try_except_handler_1; | 842 | goto try_except_handler_1; | ||
843 | } | 843 | } | ||
n | 844 | tmp_mod_expr_right_2 = mod_consts[10]; | n | 844 | tmp_condition_result_2 = tmp_truth_name_1 == 0 ? NUITKA_BOOL_FALSE : NUITKA_BOOL_TRUE; |
845 | tmp_cmp_expr_left_3 = BINARY_OPERATION_MOD_OBJECT_OBJECT_INT(tmp_mod_expr_left_2, tmp_mod_expr_right_2); | ||||
846 | if (tmp_cmp_expr_left_3 == NULL) { | ||||
847 | assert(HAS_ERROR_OCCURRED(tstate)); | ||||
848 | |||||
849 | FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb); | ||||
850 | |||||
851 | |||||
852 | exception_lineno = 18; | ||||
853 | |||||
854 | goto try_except_handler_1; | ||||
855 | } | ||||
856 | tmp_cmp_expr_right_3 = mod_consts[14]; | ||||
857 | tmp_condition_result_2 = RICH_COMPARE_EQ_NBOOL_OBJECT_INT(tmp_cmp_expr_left_3, tmp_cmp_expr_right_3); | ||||
858 | Py_DECREF(tmp_cmp_expr_left_3); | ||||
859 | if (tmp_condition_result_2 == NUITKA_BOOL_EXCEPTION) { | ||||
860 | assert(HAS_ERROR_OCCURRED(tstate)); | ||||
861 | |||||
862 | FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb); | ||||
863 | |||||
864 | |||||
865 | exception_lineno = 18; | ||||
866 | |||||
867 | goto try_except_handler_1; | ||||
868 | } | ||||
869 | if (tmp_condition_result_2 == NUITKA_BOOL_TRUE) { | 845 | if (tmp_condition_result_2 == NUITKA_BOOL_TRUE) { | ||
870 | goto branch_yes_1; | 846 | goto branch_yes_1; | ||
871 | } else { | 847 | } else { | ||
872 | goto branch_no_1; | 848 | goto branch_no_1; | ||
873 | } | 849 | } | ||
880 | 856 | ||||
881 | if (unlikely(tmp_operand_value_1 == NULL)) { | 857 | if (unlikely(tmp_operand_value_1 == NULL)) { | ||
882 | tmp_operand_value_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[18]); | 858 | tmp_operand_value_1 = GET_MODULE_VARIABLE_VALUE_FALLBACK(tstate, mod_consts[18]); | ||
883 | } | 859 | } | ||
884 | 860 | ||||
t | 885 | if (tmp_operand_value_1 == NULL) { | t | 861 | assert(!(tmp_operand_value_1 == NULL)); |
886 | assert(HAS_ERROR_OCCURRED(tstate)); | ||||
887 | |||||
888 | FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb); | ||||
889 | |||||
890 | |||||
891 | exception_lineno = 22; | ||||
892 | |||||
893 | goto try_except_handler_1; | ||||
894 | } | ||||
895 | tmp_res = CHECK_IF_TRUE(tmp_operand_value_1); | 862 | tmp_res = CHECK_IF_TRUE(tmp_operand_value_1); | ||
896 | if (tmp_res == -1) { | 863 | if (tmp_res == -1) { | ||
897 | assert(HAS_ERROR_OCCURRED(tstate)); | 864 | assert(HAS_ERROR_OCCURRED(tstate)); | ||
898 | 865 | ||||
899 | FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb); | 866 | FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb); |