Nuitka-winsvc 2.1.6__cp311-cp311-win_amd64.whl → 2.2.2__cp311-cp311-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of Nuitka-winsvc might be problematic. Click here for more details.
- {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.2.dist-info}/METADATA +1 -1
- {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.2.dist-info}/RECORD +234 -225
- nuitka/Errors.py +4 -0
- nuitka/HardImportRegistry.py +18 -1
- nuitka/MainControl.py +27 -30
- nuitka/OptionParsing.py +32 -30
- nuitka/Options.py +26 -13
- nuitka/OutputDirectories.py +7 -4
- nuitka/PostProcessing.py +9 -7
- nuitka/Progress.py +3 -3
- nuitka/PythonVersions.py +2 -2
- nuitka/TreeXML.py +1 -1
- nuitka/Version.py +1 -1
- nuitka/build/Backend.scons +2 -1
- nuitka/build/DataComposerInterface.py +1 -0
- nuitka/build/Onefile.scons +2 -1
- nuitka/build/SconsCaching.py +64 -46
- nuitka/build/SconsCompilerSettings.py +19 -6
- nuitka/build/SconsHacks.py +0 -1
- nuitka/build/SconsInterface.py +84 -5
- nuitka/build/SconsProgress.py +0 -1
- nuitka/build/SconsUtils.py +8 -4
- nuitka/build/include/nuitka/allocator.h +8 -3
- nuitka/build/include/nuitka/compiled_cell.h +8 -0
- nuitka/build/include/nuitka/exceptions.h +554 -179
- nuitka/build/include/nuitka/helper/dictionaries.h +1 -1
- nuitka/build/include/nuitka/helper/import_hard.h +3 -0
- nuitka/build/include/nuitka/helper/ints.h +15 -2
- nuitka/build/include/nuitka/helper/lists.h +4 -1
- nuitka/build/include/nuitka/helper/raising.h +12 -0
- nuitka/build/include/nuitka/helper/tuples.h +5 -1
- nuitka/build/include/nuitka/helpers.h +4 -0
- nuitka/build/include/nuitka/importing.h +3 -4
- nuitka/build/include/nuitka/jit_sources.h +25 -0
- nuitka/build/include/nuitka/prelude.h +38 -11
- nuitka/build/include/nuitka/printing.h +3 -0
- nuitka/build/include/nuitka/threading.h +2 -6
- nuitka/build/include/nuitka/type_aliases.h +27 -0
- nuitka/build/inline_copy/pkg_resources/pkg_resources/__init__.py +0 -3
- nuitka/build/inline_copy/tqdm/tqdm/version.py +1 -4
- nuitka/build/static_src/CompiledAsyncgenType.c +99 -114
- nuitka/build/static_src/CompiledCodeHelpers.c +23 -14
- nuitka/build/static_src/CompiledCoroutineType.c +96 -114
- nuitka/build/static_src/CompiledFrameType.c +14 -11
- nuitka/build/static_src/CompiledFunctionType.c +34 -7
- nuitka/build/static_src/CompiledGeneratorType.c +248 -142
- nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +60 -70
- nuitka/build/static_src/CompiledMethodType.c +8 -7
- nuitka/build/static_src/HelpersAttributes.c +2 -19
- nuitka/build/static_src/HelpersBuiltin.c +2 -1
- nuitka/build/static_src/HelpersComparisonEq.c +32 -18
- nuitka/build/static_src/HelpersComparisonGe.c +50 -36
- nuitka/build/static_src/HelpersComparisonGt.c +50 -36
- nuitka/build/static_src/HelpersComparisonLe.c +50 -36
- nuitka/build/static_src/HelpersComparisonLt.c +50 -36
- nuitka/build/static_src/HelpersComparisonNe.c +32 -18
- nuitka/build/static_src/HelpersDeepcopy.c +6 -8
- nuitka/build/static_src/HelpersDictionaries.c +8 -3
- nuitka/build/static_src/HelpersExceptions.c +42 -28
- nuitka/build/static_src/HelpersFilesystemPaths.c +7 -7
- nuitka/build/static_src/HelpersImportHard.c +15 -0
- nuitka/build/static_src/HelpersJitSources.c +46 -0
- nuitka/build/static_src/HelpersLists.c +40 -0
- nuitka/build/static_src/HelpersOperationBinaryAdd.c +66 -66
- nuitka/build/static_src/HelpersOperationBinaryAddUtils.c +80 -33
- nuitka/build/static_src/HelpersOperationBinaryMultUtils.c +16 -13
- nuitka/build/static_src/HelpersOperationBinarySub.c +39 -39
- nuitka/build/static_src/HelpersOperationInplaceAdd.c +54 -54
- nuitka/build/static_src/HelpersOperationInplaceAddUtils.c +1 -1
- nuitka/build/static_src/HelpersOperationInplaceSub.c +50 -50
- nuitka/build/static_src/HelpersProfiling.c +3 -4
- nuitka/build/static_src/HelpersRaising.c +62 -1
- nuitka/build/static_src/HelpersStrings.c +203 -8
- nuitka/build/static_src/HelpersTypes.c +42 -0
- nuitka/build/static_src/MainProgram.c +1 -1
- nuitka/build/static_src/MetaPathBasedLoader.c +2 -1
- nuitka/build/static_src/OnefileBootstrap.c +3 -3
- nuitka/code_generation/BinaryOperationHelperDefinitions.py +5 -3
- nuitka/code_generation/BuiltinCodes.py +1 -0
- nuitka/code_generation/CodeGeneration.py +11 -0
- nuitka/code_generation/CodeHelpers.py +5 -3
- nuitka/code_generation/CodeObjectCodes.py +10 -6
- nuitka/code_generation/ComparisonCodes.py +19 -3
- nuitka/code_generation/ConstantCodes.py +5 -0
- nuitka/code_generation/Contexts.py +22 -6
- nuitka/code_generation/Emission.py +1 -0
- nuitka/code_generation/ErrorCodes.py +8 -16
- nuitka/code_generation/EvalCodes.py +5 -3
- nuitka/code_generation/ExceptionCodes.py +8 -1
- nuitka/code_generation/ExpressionCTypeSelectionHelpers.py +1 -0
- nuitka/code_generation/FrameCodes.py +5 -3
- nuitka/code_generation/FunctionCodes.py +0 -1
- nuitka/code_generation/GeneratorCodes.py +3 -3
- nuitka/code_generation/GlobalConstants.py +0 -2
- nuitka/code_generation/ImportCodes.py +2 -0
- nuitka/code_generation/JitCodes.py +44 -0
- nuitka/code_generation/ListCodes.py +11 -17
- nuitka/code_generation/MatchCodes.py +0 -1
- nuitka/code_generation/ModuleCodes.py +2 -1
- nuitka/code_generation/Namify.py +0 -1
- nuitka/code_generation/NetworkxCodes.py +51 -0
- nuitka/code_generation/OperationCodes.py +8 -6
- nuitka/code_generation/PackageResourceCodes.py +7 -5
- nuitka/code_generation/TensorflowCodes.py +54 -0
- nuitka/code_generation/TypeAliasCodes.py +71 -0
- nuitka/code_generation/VariableCodes.py +7 -5
- nuitka/code_generation/VariableDeclarations.py +1 -0
- nuitka/code_generation/c_types/CTypeCLongs.py +0 -1
- nuitka/code_generation/c_types/CTypeNuitkaInts.py +0 -1
- nuitka/code_generation/c_types/CTypeVoids.py +1 -0
- nuitka/code_generation/templates/CodeTemplatesConstants.py +14 -0
- nuitka/code_generation/templates/CodeTemplatesExceptions.py +1 -1
- nuitka/code_generation/templates/CodeTemplatesIterators.py +0 -1
- nuitka/code_generation/templates/CodeTemplatesLoader.py +0 -1
- nuitka/code_generation/templates/CodeTemplatesModules.py +9 -4
- nuitka/code_generation/templates/CodeTemplatesVariables.py +8 -8
- nuitka/code_generation/templates/TemplateDebugWrapper.py +0 -1
- nuitka/code_generation/templates_c/HelperOperationComparisonUnicode.c.j2 +4 -0
- nuitka/code_generation/templates_c/HelperSlotsLong.c.j2 +9 -7
- nuitka/containers/Namedtuples.py +0 -1
- nuitka/finalizations/Finalization.py +1 -0
- nuitka/finalizations/FinalizeMarkups.py +0 -1
- nuitka/freezer/DllDependenciesMacOS.py +60 -13
- nuitka/freezer/DllDependenciesPosix.py +0 -1
- nuitka/freezer/DllDependenciesWin32.py +2 -1
- nuitka/freezer/IncludedDataFiles.py +46 -15
- nuitka/freezer/IncludedEntryPoints.py +5 -3
- nuitka/freezer/Standalone.py +6 -1
- nuitka/importing/ImportCache.py +2 -2
- nuitka/importing/ImportResolving.py +80 -78
- nuitka/importing/Importing.py +34 -1
- nuitka/nodes/AttributeNodesGenerated.py +21 -6
- nuitka/nodes/BuiltinComplexNodes.py +1 -0
- nuitka/nodes/BuiltinFormatNodes.py +1 -0
- nuitka/nodes/BuiltinIteratorNodes.py +5 -3
- nuitka/nodes/BuiltinOperationNodeBasesGenerated.py +21 -6
- nuitka/nodes/BuiltinRefNodes.py +8 -1
- nuitka/nodes/BuiltinVarsNodes.py +0 -1
- nuitka/nodes/ChildrenHavingMixins.py +906 -186
- nuitka/nodes/CodeObjectSpecs.py +1 -1
- nuitka/nodes/ConditionalNodes.py +2 -6
- nuitka/nodes/ConstantRefNodes.py +38 -0
- nuitka/nodes/CtypesNodes.py +0 -1
- nuitka/nodes/DictionaryNodes.py +0 -1
- nuitka/nodes/ExceptionNodes.py +10 -0
- nuitka/nodes/ExpressionBases.py +15 -9
- nuitka/nodes/ExpressionBasesGenerated.py +32 -15
- nuitka/nodes/FunctionNodes.py +50 -5
- nuitka/nodes/HardImportNodesGenerated.py +245 -60
- nuitka/nodes/ImportHardNodes.py +27 -13
- nuitka/nodes/ImportNodes.py +92 -70
- nuitka/nodes/InjectCNodes.py +0 -1
- nuitka/nodes/ModuleNodes.py +10 -5
- nuitka/nodes/NetworkxNodes.py +45 -0
- nuitka/nodes/OperatorNodesUnary.py +1 -0
- nuitka/nodes/OsSysNodes.py +0 -1
- nuitka/nodes/PackageMetadataNodes.py +0 -1
- nuitka/nodes/PackageResourceNodes.py +10 -6
- nuitka/nodes/StatementBasesGenerated.py +107 -60
- nuitka/nodes/StringConcatenationNodes.py +1 -0
- nuitka/nodes/TensorflowNodes.py +38 -0
- nuitka/nodes/TypeNodes.py +21 -0
- nuitka/nodes/VariableRefNodes.py +1 -0
- nuitka/nodes/shapes/BuiltinTypeShapes.py +25 -15
- nuitka/optimizations/Optimization.py +7 -6
- nuitka/optimizations/OptimizeBuiltinCalls.py +11 -9
- nuitka/optimizations/Tags.py +0 -1
- nuitka/optimizations/TraceCollections.py +6 -55
- nuitka/optimizations/ValueTraces.py +49 -1
- nuitka/plugins/PluginBase.py +26 -4
- nuitka/plugins/Plugins.py +49 -12
- nuitka/plugins/standard/AntiBloatPlugin.py +12 -2
- nuitka/plugins/standard/ConsiderPyLintAnnotationsPlugin.py +0 -1
- nuitka/plugins/standard/DataFilesPlugin.py +2 -6
- nuitka/plugins/standard/DillPlugin.py +3 -3
- nuitka/plugins/standard/DllFilesPlugin.py +29 -23
- nuitka/plugins/standard/GiPlugin.py +1 -0
- nuitka/plugins/standard/ImplicitImports.py +8 -7
- nuitka/plugins/standard/MatplotlibPlugin.py +1 -0
- nuitka/plugins/standard/OptionsNannyPlugin.py +3 -7
- nuitka/plugins/standard/PkgResourcesPlugin.py +0 -1
- nuitka/plugins/standard/PmwPlugin.py +10 -9
- nuitka/plugins/standard/PySidePyQtPlugin.py +0 -28
- nuitka/plugins/standard/TensorflowPlugin.py +1 -0
- nuitka/plugins/standard/TorchPlugin.py +1 -0
- nuitka/plugins/standard/TrioPlugin.py +1 -0
- nuitka/plugins/standard/standard.nuitka-package.config.yml +249 -34
- nuitka/reports/CompilationReportReader.py +0 -1
- nuitka/reports/Reports.py +49 -5
- nuitka/specs/BuiltinParameterSpecs.py +10 -2
- nuitka/specs/BuiltinStrOperationSpecs.py +1 -1
- nuitka/specs/BuiltinTypeOperationSpecs.py +0 -1
- nuitka/specs/HardImportSpecs.py +34 -1
- nuitka/specs/ParameterSpecs.py +11 -9
- nuitka/tools/environments/Virtualenv.py +0 -1
- nuitka/tools/specialize/CTypeDescriptions.py +15 -11
- nuitka/tools/specialize/SpecializeC.py +11 -9
- nuitka/tools/specialize/SpecializePython.py +57 -30
- nuitka/tools/testing/Common.py +24 -7
- nuitka/tools/testing/OutputComparison.py +4 -0
- nuitka/tools/testing/Pythons.py +0 -1
- nuitka/tools/testing/compare_with_cpython/__main__.py +0 -4
- nuitka/tools/watch/GitHub.py +4 -1
- nuitka/tools/watch/__main__.py +22 -1
- nuitka/tree/Building.py +3 -0
- nuitka/tree/InternalModule.py +0 -1
- nuitka/tree/ReformulationAssertStatements.py +1 -0
- nuitka/tree/ReformulationAssignmentStatements.py +26 -3
- nuitka/tree/ReformulationClasses3.py +23 -26
- nuitka/tree/ReformulationContractionExpressions.py +5 -3
- nuitka/tree/ReformulationDictionaryCreation.py +6 -5
- nuitka/tree/ReformulationExecStatements.py +8 -6
- nuitka/tree/ReformulationFunctionStatements.py +10 -6
- nuitka/tree/SourceHandling.py +8 -0
- nuitka/tree/TreeHelpers.py +6 -3
- nuitka/utils/AppDirs.py +6 -2
- nuitka/utils/CStrings.py +1 -1
- nuitka/utils/CommandLineOptions.py +0 -1
- nuitka/utils/Distributions.py +3 -3
- nuitka/utils/Download.py +5 -1
- nuitka/utils/Execution.py +6 -3
- nuitka/utils/FileOperations.py +61 -34
- nuitka/utils/Importing.py +4 -4
- nuitka/utils/InstanceCounters.py +1 -0
- nuitka/utils/MacOSApp.py +1 -0
- nuitka/utils/Shebang.py +1 -0
- nuitka/utils/Utils.py +39 -1
- nuitka/utils/WindowsFileUsage.py +4 -3
- {Nuitka_winsvc-2.1.6.data → Nuitka_winsvc-2.2.2.data}/scripts/nuitka-run.bat +0 -0
- {Nuitka_winsvc-2.1.6.data → Nuitka_winsvc-2.2.2.data}/scripts/nuitka.bat +0 -0
- {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.2.dist-info}/LICENSE.txt +0 -0
- {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.2.dist-info}/WHEEL +0 -0
- {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.2.dist-info}/entry_points.txt +0 -0
- {Nuitka_winsvc-2.1.6.dist-info → Nuitka_winsvc-2.2.2.dist-info}/top_level.txt +0 -0
|
@@ -1030,8 +1030,8 @@ static PyObject *_BINARY_OPERATION_ADD_OBJECT_LONG_LONG(PyObject *operand1, PyOb
|
|
|
1030
1030
|
|
|
1031
1031
|
PyLongObject *operand2_long_object = (PyLongObject *)operand2;
|
|
1032
1032
|
|
|
1033
|
-
if (
|
|
1034
|
-
long r = MEDIUM_VALUE(operand1_long_object) + MEDIUM_VALUE(operand2_long_object);
|
|
1033
|
+
if (Nuitka_LongGetDigitSize(operand1_long_object) <= 1 && Nuitka_LongGetDigitSize(operand2_long_object) <= 1) {
|
|
1034
|
+
long r = (long)(MEDIUM_VALUE(operand1_long_object) + MEDIUM_VALUE(operand2_long_object));
|
|
1035
1035
|
|
|
1036
1036
|
clong_result = r;
|
|
1037
1037
|
goto exit_result_ok_clong;
|
|
@@ -1040,17 +1040,17 @@ static PyObject *_BINARY_OPERATION_ADD_OBJECT_LONG_LONG(PyObject *operand1, PyOb
|
|
|
1040
1040
|
{
|
|
1041
1041
|
PyLongObject *z;
|
|
1042
1042
|
|
|
1043
|
-
digit const *a_digits = operand1_long_object
|
|
1044
|
-
Py_ssize_t a_digit_count =
|
|
1045
|
-
bool a_negative =
|
|
1046
|
-
digit const *b_digits = operand2_long_object
|
|
1047
|
-
Py_ssize_t b_digit_count =
|
|
1048
|
-
bool b_negative =
|
|
1043
|
+
digit const *a_digits = Nuitka_LongGetDigitPointer(operand1_long_object);
|
|
1044
|
+
Py_ssize_t a_digit_count = Nuitka_LongGetDigitSize(operand1_long_object);
|
|
1045
|
+
bool a_negative = Nuitka_LongIsNegative(operand1_long_object);
|
|
1046
|
+
digit const *b_digits = Nuitka_LongGetDigitPointer(operand2_long_object);
|
|
1047
|
+
Py_ssize_t b_digit_count = Nuitka_LongGetDigitSize(operand2_long_object);
|
|
1048
|
+
bool b_negative = Nuitka_LongIsNegative(operand2_long_object);
|
|
1049
1049
|
|
|
1050
1050
|
if (a_negative) {
|
|
1051
1051
|
if (b_negative) {
|
|
1052
1052
|
z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
|
|
1053
|
-
|
|
1053
|
+
Nuitka_LongFlipSign(z);
|
|
1054
1054
|
} else {
|
|
1055
1055
|
z = _Nuitka_LongSubDigits(b_digits, b_digit_count, a_digits, a_digit_count);
|
|
1056
1056
|
}
|
|
@@ -1264,8 +1264,8 @@ static PyObject *_BINARY_OPERATION_ADD_OBJECT_OBJECT_LONG(PyObject *operand1, Py
|
|
|
1264
1264
|
|
|
1265
1265
|
PyLongObject *operand2_long_object = (PyLongObject *)operand2;
|
|
1266
1266
|
|
|
1267
|
-
if (
|
|
1268
|
-
long r = MEDIUM_VALUE(operand1_long_object) + MEDIUM_VALUE(operand2_long_object);
|
|
1267
|
+
if (Nuitka_LongGetDigitSize(operand1_long_object) <= 1 && Nuitka_LongGetDigitSize(operand2_long_object) <= 1) {
|
|
1268
|
+
long r = (long)(MEDIUM_VALUE(operand1_long_object) + MEDIUM_VALUE(operand2_long_object));
|
|
1269
1269
|
|
|
1270
1270
|
clong_result = r;
|
|
1271
1271
|
goto exit_result_ok_clong;
|
|
@@ -1274,17 +1274,17 @@ static PyObject *_BINARY_OPERATION_ADD_OBJECT_OBJECT_LONG(PyObject *operand1, Py
|
|
|
1274
1274
|
{
|
|
1275
1275
|
PyLongObject *z;
|
|
1276
1276
|
|
|
1277
|
-
digit const *a_digits = operand1_long_object
|
|
1278
|
-
Py_ssize_t a_digit_count =
|
|
1279
|
-
bool a_negative =
|
|
1280
|
-
digit const *b_digits = operand2_long_object
|
|
1281
|
-
Py_ssize_t b_digit_count =
|
|
1282
|
-
bool b_negative =
|
|
1277
|
+
digit const *a_digits = Nuitka_LongGetDigitPointer(operand1_long_object);
|
|
1278
|
+
Py_ssize_t a_digit_count = Nuitka_LongGetDigitSize(operand1_long_object);
|
|
1279
|
+
bool a_negative = Nuitka_LongIsNegative(operand1_long_object);
|
|
1280
|
+
digit const *b_digits = Nuitka_LongGetDigitPointer(operand2_long_object);
|
|
1281
|
+
Py_ssize_t b_digit_count = Nuitka_LongGetDigitSize(operand2_long_object);
|
|
1282
|
+
bool b_negative = Nuitka_LongIsNegative(operand2_long_object);
|
|
1283
1283
|
|
|
1284
1284
|
if (a_negative) {
|
|
1285
1285
|
if (b_negative) {
|
|
1286
1286
|
z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
|
|
1287
|
-
|
|
1287
|
+
Nuitka_LongFlipSign(z);
|
|
1288
1288
|
} else {
|
|
1289
1289
|
z = _Nuitka_LongSubDigits(b_digits, b_digit_count, a_digits, a_digit_count);
|
|
1290
1290
|
}
|
|
@@ -1506,8 +1506,8 @@ static PyObject *_BINARY_OPERATION_ADD_OBJECT_LONG_OBJECT(PyObject *operand1, Py
|
|
|
1506
1506
|
|
|
1507
1507
|
PyLongObject *operand2_long_object = (PyLongObject *)operand2;
|
|
1508
1508
|
|
|
1509
|
-
if (
|
|
1510
|
-
long r = MEDIUM_VALUE(operand1_long_object) + MEDIUM_VALUE(operand2_long_object);
|
|
1509
|
+
if (Nuitka_LongGetDigitSize(operand1_long_object) <= 1 && Nuitka_LongGetDigitSize(operand2_long_object) <= 1) {
|
|
1510
|
+
long r = (long)(MEDIUM_VALUE(operand1_long_object) + MEDIUM_VALUE(operand2_long_object));
|
|
1511
1511
|
|
|
1512
1512
|
clong_result = r;
|
|
1513
1513
|
goto exit_result_ok_clong;
|
|
@@ -1516,17 +1516,17 @@ static PyObject *_BINARY_OPERATION_ADD_OBJECT_LONG_OBJECT(PyObject *operand1, Py
|
|
|
1516
1516
|
{
|
|
1517
1517
|
PyLongObject *z;
|
|
1518
1518
|
|
|
1519
|
-
digit const *a_digits = operand1_long_object
|
|
1520
|
-
Py_ssize_t a_digit_count =
|
|
1521
|
-
bool a_negative =
|
|
1522
|
-
digit const *b_digits = operand2_long_object
|
|
1523
|
-
Py_ssize_t b_digit_count =
|
|
1524
|
-
bool b_negative =
|
|
1519
|
+
digit const *a_digits = Nuitka_LongGetDigitPointer(operand1_long_object);
|
|
1520
|
+
Py_ssize_t a_digit_count = Nuitka_LongGetDigitSize(operand1_long_object);
|
|
1521
|
+
bool a_negative = Nuitka_LongIsNegative(operand1_long_object);
|
|
1522
|
+
digit const *b_digits = Nuitka_LongGetDigitPointer(operand2_long_object);
|
|
1523
|
+
Py_ssize_t b_digit_count = Nuitka_LongGetDigitSize(operand2_long_object);
|
|
1524
|
+
bool b_negative = Nuitka_LongIsNegative(operand2_long_object);
|
|
1525
1525
|
|
|
1526
1526
|
if (a_negative) {
|
|
1527
1527
|
if (b_negative) {
|
|
1528
1528
|
z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
|
|
1529
|
-
|
|
1529
|
+
Nuitka_LongFlipSign(z);
|
|
1530
1530
|
} else {
|
|
1531
1531
|
z = _Nuitka_LongSubDigits(b_digits, b_digit_count, a_digits, a_digit_count);
|
|
1532
1532
|
}
|
|
@@ -1591,8 +1591,8 @@ static nuitka_bool _BINARY_OPERATION_ADD_NBOOL_LONG_LONG(PyObject *operand1, PyO
|
|
|
1591
1591
|
|
|
1592
1592
|
PyLongObject *operand2_long_object = (PyLongObject *)operand2;
|
|
1593
1593
|
|
|
1594
|
-
if (
|
|
1595
|
-
long r = MEDIUM_VALUE(operand1_long_object) + MEDIUM_VALUE(operand2_long_object);
|
|
1594
|
+
if (Nuitka_LongGetDigitSize(operand1_long_object) <= 1 && Nuitka_LongGetDigitSize(operand2_long_object) <= 1) {
|
|
1595
|
+
long r = (long)(MEDIUM_VALUE(operand1_long_object) + MEDIUM_VALUE(operand2_long_object));
|
|
1596
1596
|
|
|
1597
1597
|
clong_result = r;
|
|
1598
1598
|
goto exit_result_ok_clong;
|
|
@@ -1601,17 +1601,17 @@ static nuitka_bool _BINARY_OPERATION_ADD_NBOOL_LONG_LONG(PyObject *operand1, PyO
|
|
|
1601
1601
|
{
|
|
1602
1602
|
PyLongObject *z;
|
|
1603
1603
|
|
|
1604
|
-
digit const *a_digits = operand1_long_object
|
|
1605
|
-
Py_ssize_t a_digit_count =
|
|
1606
|
-
bool a_negative =
|
|
1607
|
-
digit const *b_digits = operand2_long_object
|
|
1608
|
-
Py_ssize_t b_digit_count =
|
|
1609
|
-
bool b_negative =
|
|
1604
|
+
digit const *a_digits = Nuitka_LongGetDigitPointer(operand1_long_object);
|
|
1605
|
+
Py_ssize_t a_digit_count = Nuitka_LongGetDigitSize(operand1_long_object);
|
|
1606
|
+
bool a_negative = Nuitka_LongIsNegative(operand1_long_object);
|
|
1607
|
+
digit const *b_digits = Nuitka_LongGetDigitPointer(operand2_long_object);
|
|
1608
|
+
Py_ssize_t b_digit_count = Nuitka_LongGetDigitSize(operand2_long_object);
|
|
1609
|
+
bool b_negative = Nuitka_LongIsNegative(operand2_long_object);
|
|
1610
1610
|
|
|
1611
1611
|
if (a_negative) {
|
|
1612
1612
|
if (b_negative) {
|
|
1613
1613
|
z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
|
|
1614
|
-
|
|
1614
|
+
Nuitka_LongFlipSign(z);
|
|
1615
1615
|
} else {
|
|
1616
1616
|
z = _Nuitka_LongSubDigits(b_digits, b_digit_count, a_digits, a_digit_count);
|
|
1617
1617
|
}
|
|
@@ -1835,8 +1835,8 @@ static nuitka_bool _BINARY_OPERATION_ADD_NBOOL_OBJECT_LONG(PyObject *operand1, P
|
|
|
1835
1835
|
|
|
1836
1836
|
PyLongObject *operand2_long_object = (PyLongObject *)operand2;
|
|
1837
1837
|
|
|
1838
|
-
if (
|
|
1839
|
-
long r = MEDIUM_VALUE(operand1_long_object) + MEDIUM_VALUE(operand2_long_object);
|
|
1838
|
+
if (Nuitka_LongGetDigitSize(operand1_long_object) <= 1 && Nuitka_LongGetDigitSize(operand2_long_object) <= 1) {
|
|
1839
|
+
long r = (long)(MEDIUM_VALUE(operand1_long_object) + MEDIUM_VALUE(operand2_long_object));
|
|
1840
1840
|
|
|
1841
1841
|
clong_result = r;
|
|
1842
1842
|
goto exit_result_ok_clong;
|
|
@@ -1845,17 +1845,17 @@ static nuitka_bool _BINARY_OPERATION_ADD_NBOOL_OBJECT_LONG(PyObject *operand1, P
|
|
|
1845
1845
|
{
|
|
1846
1846
|
PyLongObject *z;
|
|
1847
1847
|
|
|
1848
|
-
digit const *a_digits = operand1_long_object
|
|
1849
|
-
Py_ssize_t a_digit_count =
|
|
1850
|
-
bool a_negative =
|
|
1851
|
-
digit const *b_digits = operand2_long_object
|
|
1852
|
-
Py_ssize_t b_digit_count =
|
|
1853
|
-
bool b_negative =
|
|
1848
|
+
digit const *a_digits = Nuitka_LongGetDigitPointer(operand1_long_object);
|
|
1849
|
+
Py_ssize_t a_digit_count = Nuitka_LongGetDigitSize(operand1_long_object);
|
|
1850
|
+
bool a_negative = Nuitka_LongIsNegative(operand1_long_object);
|
|
1851
|
+
digit const *b_digits = Nuitka_LongGetDigitPointer(operand2_long_object);
|
|
1852
|
+
Py_ssize_t b_digit_count = Nuitka_LongGetDigitSize(operand2_long_object);
|
|
1853
|
+
bool b_negative = Nuitka_LongIsNegative(operand2_long_object);
|
|
1854
1854
|
|
|
1855
1855
|
if (a_negative) {
|
|
1856
1856
|
if (b_negative) {
|
|
1857
1857
|
z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
|
|
1858
|
-
|
|
1858
|
+
Nuitka_LongFlipSign(z);
|
|
1859
1859
|
} else {
|
|
1860
1860
|
z = _Nuitka_LongSubDigits(b_digits, b_digit_count, a_digits, a_digit_count);
|
|
1861
1861
|
}
|
|
@@ -2087,8 +2087,8 @@ static nuitka_bool _BINARY_OPERATION_ADD_NBOOL_LONG_OBJECT(PyObject *operand1, P
|
|
|
2087
2087
|
|
|
2088
2088
|
PyLongObject *operand2_long_object = (PyLongObject *)operand2;
|
|
2089
2089
|
|
|
2090
|
-
if (
|
|
2091
|
-
long r = MEDIUM_VALUE(operand1_long_object) + MEDIUM_VALUE(operand2_long_object);
|
|
2090
|
+
if (Nuitka_LongGetDigitSize(operand1_long_object) <= 1 && Nuitka_LongGetDigitSize(operand2_long_object) <= 1) {
|
|
2091
|
+
long r = (long)(MEDIUM_VALUE(operand1_long_object) + MEDIUM_VALUE(operand2_long_object));
|
|
2092
2092
|
|
|
2093
2093
|
clong_result = r;
|
|
2094
2094
|
goto exit_result_ok_clong;
|
|
@@ -2097,17 +2097,17 @@ static nuitka_bool _BINARY_OPERATION_ADD_NBOOL_LONG_OBJECT(PyObject *operand1, P
|
|
|
2097
2097
|
{
|
|
2098
2098
|
PyLongObject *z;
|
|
2099
2099
|
|
|
2100
|
-
digit const *a_digits = operand1_long_object
|
|
2101
|
-
Py_ssize_t a_digit_count =
|
|
2102
|
-
bool a_negative =
|
|
2103
|
-
digit const *b_digits = operand2_long_object
|
|
2104
|
-
Py_ssize_t b_digit_count =
|
|
2105
|
-
bool b_negative =
|
|
2100
|
+
digit const *a_digits = Nuitka_LongGetDigitPointer(operand1_long_object);
|
|
2101
|
+
Py_ssize_t a_digit_count = Nuitka_LongGetDigitSize(operand1_long_object);
|
|
2102
|
+
bool a_negative = Nuitka_LongIsNegative(operand1_long_object);
|
|
2103
|
+
digit const *b_digits = Nuitka_LongGetDigitPointer(operand2_long_object);
|
|
2104
|
+
Py_ssize_t b_digit_count = Nuitka_LongGetDigitSize(operand2_long_object);
|
|
2105
|
+
bool b_negative = Nuitka_LongIsNegative(operand2_long_object);
|
|
2106
2106
|
|
|
2107
2107
|
if (a_negative) {
|
|
2108
2108
|
if (b_negative) {
|
|
2109
2109
|
z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
|
|
2110
|
-
|
|
2110
|
+
Nuitka_LongFlipSign(z);
|
|
2111
2111
|
} else {
|
|
2112
2112
|
z = _Nuitka_LongSubDigits(b_digits, b_digit_count, a_digits, a_digit_count);
|
|
2113
2113
|
}
|
|
@@ -3543,8 +3543,8 @@ static PyObject *_BINARY_OPERATION_ADD_OBJECT_LONG_DIGIT(PyObject *operand1, lon
|
|
|
3543
3543
|
|
|
3544
3544
|
PyLongObject *operand1_long_object = (PyLongObject *)operand1;
|
|
3545
3545
|
|
|
3546
|
-
if (
|
|
3547
|
-
long r = MEDIUM_VALUE(operand1_long_object) + (sdigit)operand2;
|
|
3546
|
+
if (Nuitka_LongGetDigitSize(operand1_long_object) <= 1 && (operand2 == 0 ? 0 : 1) <= 1) {
|
|
3547
|
+
long r = (long)(MEDIUM_VALUE(operand1_long_object) + (sdigit)operand2);
|
|
3548
3548
|
|
|
3549
3549
|
clong_result = r;
|
|
3550
3550
|
goto exit_result_ok_clong;
|
|
@@ -3553,9 +3553,9 @@ static PyObject *_BINARY_OPERATION_ADD_OBJECT_LONG_DIGIT(PyObject *operand1, lon
|
|
|
3553
3553
|
{
|
|
3554
3554
|
PyLongObject *z;
|
|
3555
3555
|
|
|
3556
|
-
digit const *a_digits = operand1_long_object
|
|
3557
|
-
Py_ssize_t a_digit_count =
|
|
3558
|
-
bool a_negative =
|
|
3556
|
+
digit const *a_digits = Nuitka_LongGetDigitPointer(operand1_long_object);
|
|
3557
|
+
Py_ssize_t a_digit_count = Nuitka_LongGetDigitSize(operand1_long_object);
|
|
3558
|
+
bool a_negative = Nuitka_LongIsNegative(operand1_long_object);
|
|
3559
3559
|
digit const *b_digits = (digit *)&operand2;
|
|
3560
3560
|
Py_ssize_t b_digit_count = (operand2 == 0 ? 0 : 1);
|
|
3561
3561
|
bool b_negative = operand2 < 0;
|
|
@@ -3563,7 +3563,7 @@ static PyObject *_BINARY_OPERATION_ADD_OBJECT_LONG_DIGIT(PyObject *operand1, lon
|
|
|
3563
3563
|
if (a_negative) {
|
|
3564
3564
|
if (b_negative) {
|
|
3565
3565
|
z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
|
|
3566
|
-
|
|
3566
|
+
Nuitka_LongFlipSign(z);
|
|
3567
3567
|
} else {
|
|
3568
3568
|
z = _Nuitka_LongSubDigits(b_digits, b_digit_count, a_digits, a_digit_count);
|
|
3569
3569
|
}
|
|
@@ -3623,8 +3623,8 @@ static nuitka_bool _BINARY_OPERATION_ADD_NBOOL_LONG_DIGIT(PyObject *operand1, lo
|
|
|
3623
3623
|
|
|
3624
3624
|
PyLongObject *operand1_long_object = (PyLongObject *)operand1;
|
|
3625
3625
|
|
|
3626
|
-
if (
|
|
3627
|
-
long r = MEDIUM_VALUE(operand1_long_object) + (sdigit)operand2;
|
|
3626
|
+
if (Nuitka_LongGetDigitSize(operand1_long_object) <= 1 && (operand2 == 0 ? 0 : 1) <= 1) {
|
|
3627
|
+
long r = (long)(MEDIUM_VALUE(operand1_long_object) + (sdigit)operand2);
|
|
3628
3628
|
|
|
3629
3629
|
clong_result = r;
|
|
3630
3630
|
goto exit_result_ok_clong;
|
|
@@ -3633,9 +3633,9 @@ static nuitka_bool _BINARY_OPERATION_ADD_NBOOL_LONG_DIGIT(PyObject *operand1, lo
|
|
|
3633
3633
|
{
|
|
3634
3634
|
PyLongObject *z;
|
|
3635
3635
|
|
|
3636
|
-
digit const *a_digits = operand1_long_object
|
|
3637
|
-
Py_ssize_t a_digit_count =
|
|
3638
|
-
bool a_negative =
|
|
3636
|
+
digit const *a_digits = Nuitka_LongGetDigitPointer(operand1_long_object);
|
|
3637
|
+
Py_ssize_t a_digit_count = Nuitka_LongGetDigitSize(operand1_long_object);
|
|
3638
|
+
bool a_negative = Nuitka_LongIsNegative(operand1_long_object);
|
|
3639
3639
|
digit const *b_digits = (digit *)&operand2;
|
|
3640
3640
|
Py_ssize_t b_digit_count = (operand2 == 0 ? 0 : 1);
|
|
3641
3641
|
bool b_negative = operand2 < 0;
|
|
@@ -3643,7 +3643,7 @@ static nuitka_bool _BINARY_OPERATION_ADD_NBOOL_LONG_DIGIT(PyObject *operand1, lo
|
|
|
3643
3643
|
if (a_negative) {
|
|
3644
3644
|
if (b_negative) {
|
|
3645
3645
|
z = _Nuitka_LongAddDigits(a_digits, a_digit_count, b_digits, b_digit_count);
|
|
3646
|
-
|
|
3646
|
+
Nuitka_LongFlipSign(z);
|
|
3647
3647
|
} else {
|
|
3648
3648
|
z = _Nuitka_LongSubDigits(b_digits, b_digit_count, a_digits, a_digit_count);
|
|
3649
3649
|
}
|
|
@@ -43,26 +43,59 @@ static PyObject *LIST_CONCAT(PyObject *operand1, PyObject *operand2) {
|
|
|
43
43
|
return (PyObject *)result;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
// Convert single digit to sdigit (int32_t)
|
|
47
|
-
#define MEDIUM_VALUE(x) \
|
|
48
|
-
(Py_SIZE(x) < 0 ? -(sdigit)((PyLongObject *)(x))->ob_digit[0] \
|
|
49
|
-
: (Py_SIZE(x) == 0 ? (sdigit)0 : (sdigit)((PyLongObject *)(x))->ob_digit[0]))
|
|
50
|
-
|
|
51
46
|
// Needed for offsetof
|
|
52
47
|
#include <stddef.h>
|
|
53
48
|
|
|
49
|
+
#if PYTHON_VERSION < 0x3c0
|
|
54
50
|
#define MAX_LONG_DIGITS ((PY_SSIZE_T_MAX - offsetof(PyLongObject, ob_digit)) / sizeof(digit))
|
|
55
51
|
#define Nuitka_LongGetDigitPointer(value) (&(((PyLongObject *)value)->ob_digit[0]))
|
|
56
52
|
#define Nuitka_LongGetDigitSize(value) (Py_ABS(Py_SIZE(value)))
|
|
53
|
+
#define Nuitka_LongGetSignedDigitSize(value) (Py_SIZE(value))
|
|
54
|
+
#define Nuitka_LongIsNegative(value) (Py_SIZE(value) < 0)
|
|
55
|
+
#define Nuitka_LongSetSignNegative(value) Py_SET_SIZE(value, -Py_ABS(Py_SIZE(value)))
|
|
56
|
+
#define Nuitka_LongSetSign(value, positive) Py_SET_SIZE(value, (((positive) ? 1 : -1) * Py_ABS(Py_SIZE(value))))
|
|
57
|
+
#define Nuitka_LongFlipSign(value) Py_SET_SIZE(value, -Py_SIZE(value))
|
|
58
|
+
#define Nuitka_LongSetDigitSizeAndNegative(value, count, negative) Py_SET_SIZE(value, negative ? -count : count)
|
|
59
|
+
#else
|
|
60
|
+
#define MAX_LONG_DIGITS ((PY_SSIZE_T_MAX - offsetof(PyLongObject, long_value.ob_digit)) / sizeof(digit))
|
|
61
|
+
|
|
62
|
+
#define Nuitka_LongGetDigitPointer(value) (&(((PyLongObject *)value)->long_value.ob_digit[0]))
|
|
63
|
+
#define Nuitka_LongGetDigitSize(value) (_PyLong_DigitCount((PyLongObject const *)(value)))
|
|
64
|
+
#define Nuitka_LongGetSignedDigitSize(value) (_PyLong_SignedDigitCount((PyLongObject const *)(value)))
|
|
65
|
+
#define Nuitka_LongIsNegative(value) (((PyLongObject *)value)->long_value.lv_tag & SIGN_NEGATIVE)
|
|
66
|
+
#define Nuitka_LongSetSignNegative(value) \
|
|
67
|
+
((PyLongObject *)value)->long_value.lv_tag = ((PyLongObject *)value)->long_value.lv_tag | SIGN_NEGATIVE;
|
|
68
|
+
#define Nuitka_LongSetSignPositive(value) \
|
|
69
|
+
((PyLongObject *)value)->long_value.lv_tag = ((PyLongObject *)value)->long_value.lv_tag & ~(SIGN_NEGATIVE);
|
|
70
|
+
#define Nuitka_LongSetSign(value, positive) \
|
|
71
|
+
if (positive) { \
|
|
72
|
+
Nuitka_LongSetSignPositive(value); \
|
|
73
|
+
} else { \
|
|
74
|
+
Nuitka_LongSetSignNegative(value); \
|
|
75
|
+
}
|
|
76
|
+
#define Nuitka_LongSetDigitSizeAndNegative(value, count, negative) \
|
|
77
|
+
_PyLong_SetSignAndDigitCount(value, negative ? -1 : 1, count)
|
|
78
|
+
#define Nuitka_LongFlipSign(value) _PyLong_FlipSign(value)
|
|
79
|
+
#endif
|
|
57
80
|
|
|
58
81
|
// Our version of _PyLong_New(size);
|
|
59
82
|
static PyLongObject *Nuitka_LongNew(Py_ssize_t size) {
|
|
83
|
+
// TODO: The assertion may be a bit to strong, could be <= for at least < 3.12
|
|
60
84
|
assert(size < (Py_ssize_t)MAX_LONG_DIGITS);
|
|
85
|
+
assert(size >= 0);
|
|
61
86
|
|
|
62
|
-
#if PYTHON_VERSION >=
|
|
63
|
-
|
|
87
|
+
#if PYTHON_VERSION >= 0x3c0
|
|
88
|
+
// The zero now is a single digit number.
|
|
89
|
+
Py_ssize_t ndigits = size ? size : 1;
|
|
64
90
|
|
|
65
|
-
|
|
91
|
+
PyLongObject *result =
|
|
92
|
+
(PyLongObject *)PyObject_MALLOC(offsetof(PyLongObject, long_value.ob_digit) + ndigits * sizeof(digit));
|
|
93
|
+
_PyLong_SetSignAndDigitCount(result, size != 0, size);
|
|
94
|
+
PyObject_INIT(result, &PyLong_Type);
|
|
95
|
+
result->long_value.ob_digit[0] = 0;
|
|
96
|
+
return result;
|
|
97
|
+
#elif PYTHON_VERSION >= 0x300
|
|
98
|
+
PyLongObject *result = (PyLongObject *)PyObject_MALLOC(offsetof(PyLongObject, ob_digit) + size * sizeof(digit));
|
|
66
99
|
return (PyLongObject *)PyObject_INIT_VAR(result, &PyLong_Type, size);
|
|
67
100
|
#else
|
|
68
101
|
return (PyLongObject *)PyObject_NEW_VAR(PyLongObject, &PyLong_Type, size);
|
|
@@ -70,8 +103,10 @@ static PyLongObject *Nuitka_LongNew(Py_ssize_t size) {
|
|
|
70
103
|
}
|
|
71
104
|
|
|
72
105
|
static PyObject *Nuitka_LongRealloc(PyObject *value, Py_ssize_t size) {
|
|
106
|
+
assert(size >= 0);
|
|
107
|
+
|
|
73
108
|
PyLongObject *result = Nuitka_LongNew(size);
|
|
74
|
-
|
|
109
|
+
Nuitka_LongSetDigitSizeAndNegative(result, size, false);
|
|
75
110
|
Py_DECREF(value);
|
|
76
111
|
|
|
77
112
|
return (PyObject *)result;
|
|
@@ -111,10 +146,11 @@ static PyObject *Nuitka_LongFromCLong(long ival) {
|
|
|
111
146
|
PyLongObject *result = Nuitka_LongNew(1);
|
|
112
147
|
assert(result != NULL);
|
|
113
148
|
if (negative) {
|
|
114
|
-
|
|
149
|
+
Nuitka_LongSetSignNegative(result);
|
|
115
150
|
}
|
|
116
151
|
|
|
117
|
-
|
|
152
|
+
digit *digits = Nuitka_LongGetDigitPointer(result);
|
|
153
|
+
digits[0] = (digit)abs_ival;
|
|
118
154
|
|
|
119
155
|
return (PyObject *)result;
|
|
120
156
|
}
|
|
@@ -125,11 +161,13 @@ static PyObject *Nuitka_LongFromCLong(long ival) {
|
|
|
125
161
|
PyLongObject *result = Nuitka_LongNew(2);
|
|
126
162
|
assert(result != NULL);
|
|
127
163
|
if (negative) {
|
|
128
|
-
|
|
164
|
+
Nuitka_LongSetSignNegative(result);
|
|
129
165
|
}
|
|
130
166
|
|
|
131
|
-
|
|
132
|
-
|
|
167
|
+
digit *digits = Nuitka_LongGetDigitPointer(result);
|
|
168
|
+
|
|
169
|
+
digits[0] = (digit)(abs_ival & PyLong_MASK);
|
|
170
|
+
digits[1] = (digit)(abs_ival >> PyLong_SHIFT);
|
|
133
171
|
|
|
134
172
|
return (PyObject *)result;
|
|
135
173
|
}
|
|
@@ -148,9 +186,9 @@ static PyObject *Nuitka_LongFromCLong(long ival) {
|
|
|
148
186
|
PyLongObject *result = _PyLong_New(ndigits);
|
|
149
187
|
assert(result != NULL);
|
|
150
188
|
|
|
151
|
-
|
|
189
|
+
Nuitka_LongSetDigitSizeAndNegative(result, ndigits, negative);
|
|
152
190
|
|
|
153
|
-
digit *d = result
|
|
191
|
+
digit *d = Nuitka_LongGetDigitPointer(result);
|
|
154
192
|
|
|
155
193
|
// Now copy the digits
|
|
156
194
|
t = abs_ival;
|
|
@@ -204,18 +242,22 @@ static void Nuitka_LongUpdateFromCLong(PyObject **value, long ival) {
|
|
|
204
242
|
if (!(abs_ival >> PyLong_SHIFT)) {
|
|
205
243
|
PyLongObject *result;
|
|
206
244
|
|
|
245
|
+
#if PYTHON_VERSION < 0x3c0
|
|
207
246
|
if (unlikely(Py_SIZE(*value) == 0)) {
|
|
208
247
|
*value = Nuitka_LongRealloc(*value, 1);
|
|
209
248
|
CHECK_OBJECT(*value);
|
|
210
249
|
|
|
211
250
|
result = (PyLongObject *)*value;
|
|
212
|
-
} else
|
|
251
|
+
} else
|
|
252
|
+
#endif
|
|
253
|
+
{
|
|
213
254
|
result = (PyLongObject *)(*value);
|
|
214
255
|
}
|
|
215
256
|
|
|
216
|
-
|
|
257
|
+
Nuitka_LongSetSign(result, !negative);
|
|
217
258
|
|
|
218
|
-
|
|
259
|
+
digit *digits = Nuitka_LongGetDigitPointer(result);
|
|
260
|
+
digits[0] = (digit)abs_ival;
|
|
219
261
|
|
|
220
262
|
return;
|
|
221
263
|
}
|
|
@@ -233,10 +275,14 @@ static void Nuitka_LongUpdateFromCLong(PyObject **value, long ival) {
|
|
|
233
275
|
result = (PyLongObject *)(*value);
|
|
234
276
|
}
|
|
235
277
|
|
|
236
|
-
|
|
278
|
+
if (negative) {
|
|
279
|
+
Nuitka_LongSetSignNegative(result);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
digit *digits = Nuitka_LongGetDigitPointer(result);
|
|
237
283
|
|
|
238
|
-
|
|
239
|
-
|
|
284
|
+
digits[0] = (digit)(abs_ival & PyLong_MASK);
|
|
285
|
+
digits[1] = (digit)(abs_ival >> PyLong_SHIFT);
|
|
240
286
|
|
|
241
287
|
return;
|
|
242
288
|
}
|
|
@@ -258,9 +304,9 @@ static void Nuitka_LongUpdateFromCLong(PyObject **value, long ival) {
|
|
|
258
304
|
|
|
259
305
|
CHECK_OBJECT(*value);
|
|
260
306
|
|
|
261
|
-
|
|
307
|
+
Nuitka_LongSetDigitSizeAndNegative((PyLongObject *)*value, ndigits, negative);
|
|
262
308
|
|
|
263
|
-
digit *d = (
|
|
309
|
+
digit *d = Nuitka_LongGetDigitPointer(*value);
|
|
264
310
|
|
|
265
311
|
// Now copy the digits
|
|
266
312
|
t = abs_ival;
|
|
@@ -310,7 +356,7 @@ static PyLongObject *_Nuitka_LongAddDigits(digit const *a, Py_ssize_t size_a, di
|
|
|
310
356
|
PyLongObject *result = Nuitka_LongNew(size_a + 1);
|
|
311
357
|
CHECK_OBJECT(result);
|
|
312
358
|
|
|
313
|
-
digit *r =
|
|
359
|
+
digit *r = Nuitka_LongGetDigitPointer(result);
|
|
314
360
|
|
|
315
361
|
digit carry = 0;
|
|
316
362
|
|
|
@@ -332,7 +378,8 @@ static PyLongObject *_Nuitka_LongAddDigits(digit const *a, Py_ssize_t size_a, di
|
|
|
332
378
|
if (carry) {
|
|
333
379
|
r[i] = carry;
|
|
334
380
|
} else {
|
|
335
|
-
|
|
381
|
+
// Note: Beware, this looses the sign value.
|
|
382
|
+
Nuitka_LongSetDigitSizeAndNegative(result, Nuitka_LongGetDigitSize(result) - 1, false);
|
|
336
383
|
}
|
|
337
384
|
|
|
338
385
|
return result;
|
|
@@ -417,9 +464,9 @@ static PyObject *_Nuitka_LongAddInplaceDigits(PyObject *left, digit const *b, Py
|
|
|
417
464
|
if (carry != 0) {
|
|
418
465
|
r[i] = carry;
|
|
419
466
|
|
|
420
|
-
|
|
467
|
+
Nuitka_LongSetDigitSizeAndNegative((PyLongObject *)left, i + 1, false);
|
|
421
468
|
} else {
|
|
422
|
-
|
|
469
|
+
Nuitka_LongSetDigitSizeAndNegative((PyLongObject *)left, i, false);
|
|
423
470
|
}
|
|
424
471
|
|
|
425
472
|
// Release reference to old value
|
|
@@ -480,7 +527,7 @@ static PyLongObject *_Nuitka_LongSubDigits(digit const *a, Py_ssize_t size_a, di
|
|
|
480
527
|
PyLongObject *result = Nuitka_LongNew(size_a);
|
|
481
528
|
CHECK_OBJECT(result);
|
|
482
529
|
|
|
483
|
-
digit *r =
|
|
530
|
+
digit *r = Nuitka_LongGetDigitPointer(result);
|
|
484
531
|
|
|
485
532
|
digit borrow = 0;
|
|
486
533
|
|
|
@@ -506,12 +553,12 @@ static PyLongObject *_Nuitka_LongSubDigits(digit const *a, Py_ssize_t size_a, di
|
|
|
506
553
|
i -= 1;
|
|
507
554
|
}
|
|
508
555
|
|
|
509
|
-
|
|
556
|
+
Nuitka_LongSetDigitSizeAndNegative(result, i, sign < 0);
|
|
510
557
|
|
|
511
558
|
#if PYTHON_VERSION >= 0x300
|
|
512
559
|
// Normalize small integers.
|
|
513
560
|
if (i <= 1) {
|
|
514
|
-
|
|
561
|
+
medium_result_value_t ival = MEDIUM_VALUE(result);
|
|
515
562
|
|
|
516
563
|
if (ival >= NUITKA_STATIC_SMALLINT_VALUE_MIN && ival < NUITKA_STATIC_SMALLINT_VALUE_MAX) {
|
|
517
564
|
Py_DECREF(result);
|
|
@@ -615,7 +662,7 @@ static PyObject *_Nuitka_LongSubInplaceDigits(PyObject *left, digit const *b, Py
|
|
|
615
662
|
i -= 1;
|
|
616
663
|
}
|
|
617
664
|
|
|
618
|
-
|
|
665
|
+
Nuitka_LongSetDigitSizeAndNegative((PyLongObject *)left, i, (sign < 0));
|
|
619
666
|
|
|
620
667
|
// Release reference to old value
|
|
621
668
|
Py_DECREF(old);
|
|
@@ -623,7 +670,7 @@ static PyObject *_Nuitka_LongSubInplaceDigits(PyObject *left, digit const *b, Py
|
|
|
623
670
|
#if PYTHON_VERSION >= 0x300
|
|
624
671
|
// Normalize small integers.
|
|
625
672
|
if (i <= 1) {
|
|
626
|
-
|
|
673
|
+
medium_result_value_t ival = MEDIUM_VALUE(left);
|
|
627
674
|
|
|
628
675
|
if (ival >= NUITKA_STATIC_SMALLINT_VALUE_MIN && ival < NUITKA_STATIC_SMALLINT_VALUE_MAX) {
|
|
629
676
|
Py_DECREF(left);
|
|
@@ -14,28 +14,31 @@
|
|
|
14
14
|
|
|
15
15
|
static Py_ssize_t CONVERT_LONG_TO_REPEAT_FACTOR(PyObject *value) {
|
|
16
16
|
/* Inline PyLong_AsSsize_t here for our special purpose. */
|
|
17
|
-
|
|
17
|
+
assert(PyLong_Check(value));
|
|
18
|
+
|
|
19
|
+
Py_ssize_t digits_count = Nuitka_LongGetDigitSize(value);
|
|
18
20
|
|
|
19
|
-
if (
|
|
21
|
+
if (digits_count == 0) {
|
|
20
22
|
return 0;
|
|
21
23
|
}
|
|
22
24
|
|
|
25
|
+
bool is_negative = Nuitka_LongIsNegative(value);
|
|
26
|
+
|
|
23
27
|
PyLongObject *long_value = (PyLongObject *)value;
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
digit *digits = Nuitka_LongGetDigitPointer(long_value);
|
|
30
|
+
|
|
31
|
+
if ((digits_count == 1) && (is_negative == false)) {
|
|
32
|
+
return digits[0];
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
Py_ssize_t result = 0;
|
|
30
36
|
|
|
31
|
-
|
|
32
|
-
if (is_negative) {
|
|
33
|
-
i = -i;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
while (--i >= 0) {
|
|
37
|
+
while (--digits_count >= 0) {
|
|
37
38
|
Py_ssize_t prev = result;
|
|
38
|
-
result = (result << PyLong_SHIFT) |
|
|
39
|
+
result = (result << PyLong_SHIFT) | digits[digits_count];
|
|
40
|
+
|
|
41
|
+
// Overflow detection.
|
|
39
42
|
if ((result >> PyLong_SHIFT) != prev) {
|
|
40
43
|
return (Py_ssize_t)-1;
|
|
41
44
|
}
|
|
@@ -43,9 +46,9 @@ static Py_ssize_t CONVERT_LONG_TO_REPEAT_FACTOR(PyObject *value) {
|
|
|
43
46
|
|
|
44
47
|
if (is_negative) {
|
|
45
48
|
return 0;
|
|
46
|
-
} else {
|
|
47
|
-
return result;
|
|
48
49
|
}
|
|
50
|
+
|
|
51
|
+
return result;
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
static Py_ssize_t CONVERT_TO_REPEAT_FACTOR(PyObject *value) {
|