Nuitka-winsvc 2.1.5__cp311-cp311-win_amd64.whl → 2.2.1__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.

Files changed (234) hide show
  1. {Nuitka_winsvc-2.1.5.dist-info → Nuitka_winsvc-2.2.1.dist-info}/METADATA +1 -1
  2. {Nuitka_winsvc-2.1.5.dist-info → Nuitka_winsvc-2.2.1.dist-info}/RECORD +234 -225
  3. nuitka/Errors.py +4 -0
  4. nuitka/HardImportRegistry.py +18 -1
  5. nuitka/MainControl.py +27 -30
  6. nuitka/OptionParsing.py +32 -30
  7. nuitka/Options.py +26 -13
  8. nuitka/OutputDirectories.py +7 -4
  9. nuitka/PostProcessing.py +9 -7
  10. nuitka/Progress.py +3 -3
  11. nuitka/PythonVersions.py +2 -2
  12. nuitka/TreeXML.py +1 -1
  13. nuitka/Version.py +1 -1
  14. nuitka/build/Backend.scons +2 -1
  15. nuitka/build/DataComposerInterface.py +1 -0
  16. nuitka/build/Onefile.scons +2 -1
  17. nuitka/build/SconsCaching.py +64 -46
  18. nuitka/build/SconsCompilerSettings.py +19 -6
  19. nuitka/build/SconsHacks.py +0 -1
  20. nuitka/build/SconsInterface.py +84 -5
  21. nuitka/build/SconsProgress.py +0 -1
  22. nuitka/build/SconsUtils.py +9 -5
  23. nuitka/build/include/nuitka/allocator.h +8 -3
  24. nuitka/build/include/nuitka/compiled_cell.h +8 -0
  25. nuitka/build/include/nuitka/constants.h +2 -0
  26. nuitka/build/include/nuitka/exceptions.h +554 -179
  27. nuitka/build/include/nuitka/helper/dictionaries.h +1 -1
  28. nuitka/build/include/nuitka/helper/import_hard.h +3 -0
  29. nuitka/build/include/nuitka/helper/ints.h +15 -2
  30. nuitka/build/include/nuitka/helper/lists.h +4 -1
  31. nuitka/build/include/nuitka/helper/raising.h +12 -0
  32. nuitka/build/include/nuitka/helper/tuples.h +5 -1
  33. nuitka/build/include/nuitka/helpers.h +5 -0
  34. nuitka/build/include/nuitka/importing.h +3 -4
  35. nuitka/build/include/nuitka/jit_sources.h +25 -0
  36. nuitka/build/include/nuitka/prelude.h +38 -11
  37. nuitka/build/include/nuitka/printing.h +3 -0
  38. nuitka/build/include/nuitka/threading.h +2 -6
  39. nuitka/build/include/nuitka/type_aliases.h +27 -0
  40. nuitka/build/inline_copy/pkg_resources/pkg_resources/__init__.py +0 -3
  41. nuitka/build/inline_copy/tqdm/tqdm/version.py +1 -4
  42. nuitka/build/static_src/CompiledAsyncgenType.c +99 -114
  43. nuitka/build/static_src/CompiledCodeHelpers.c +24 -14
  44. nuitka/build/static_src/CompiledCoroutineType.c +96 -114
  45. nuitka/build/static_src/CompiledFrameType.c +14 -11
  46. nuitka/build/static_src/CompiledFunctionType.c +34 -7
  47. nuitka/build/static_src/CompiledGeneratorType.c +248 -142
  48. nuitka/build/static_src/CompiledGeneratorTypeUncompiledIntegration.c +60 -70
  49. nuitka/build/static_src/CompiledMethodType.c +8 -7
  50. nuitka/build/static_src/HelpersAttributes.c +2 -19
  51. nuitka/build/static_src/HelpersBuiltin.c +2 -1
  52. nuitka/build/static_src/HelpersComparisonEq.c +32 -18
  53. nuitka/build/static_src/HelpersComparisonGe.c +50 -36
  54. nuitka/build/static_src/HelpersComparisonGt.c +50 -36
  55. nuitka/build/static_src/HelpersComparisonLe.c +50 -36
  56. nuitka/build/static_src/HelpersComparisonLt.c +50 -36
  57. nuitka/build/static_src/HelpersComparisonNe.c +32 -18
  58. nuitka/build/static_src/HelpersDeepcopy.c +6 -8
  59. nuitka/build/static_src/HelpersDictionaries.c +8 -3
  60. nuitka/build/static_src/HelpersExceptions.c +36 -22
  61. nuitka/build/static_src/HelpersFiles.c +9 -0
  62. nuitka/build/static_src/HelpersFilesystemPaths.c +7 -7
  63. nuitka/build/static_src/HelpersImportHard.c +15 -0
  64. nuitka/build/static_src/HelpersJitSources.c +46 -0
  65. nuitka/build/static_src/HelpersLists.c +40 -0
  66. nuitka/build/static_src/HelpersOperationBinaryAdd.c +66 -66
  67. nuitka/build/static_src/HelpersOperationBinaryAddUtils.c +80 -33
  68. nuitka/build/static_src/HelpersOperationBinaryMultUtils.c +16 -13
  69. nuitka/build/static_src/HelpersOperationBinarySub.c +39 -39
  70. nuitka/build/static_src/HelpersOperationInplaceAdd.c +54 -54
  71. nuitka/build/static_src/HelpersOperationInplaceAddUtils.c +1 -1
  72. nuitka/build/static_src/HelpersOperationInplaceSub.c +50 -50
  73. nuitka/build/static_src/HelpersProfiling.c +3 -4
  74. nuitka/build/static_src/HelpersRaising.c +62 -1
  75. nuitka/build/static_src/HelpersStrings.c +203 -8
  76. nuitka/build/static_src/HelpersTypes.c +42 -0
  77. nuitka/build/static_src/MainProgram.c +1 -1
  78. nuitka/build/static_src/MetaPathBasedLoader.c +2 -1
  79. nuitka/build/static_src/OnefileBootstrap.c +3 -3
  80. nuitka/code_generation/BinaryOperationHelperDefinitions.py +5 -3
  81. nuitka/code_generation/BuiltinCodes.py +1 -0
  82. nuitka/code_generation/CodeGeneration.py +11 -0
  83. nuitka/code_generation/CodeHelpers.py +5 -3
  84. nuitka/code_generation/CodeObjectCodes.py +10 -6
  85. nuitka/code_generation/ComparisonCodes.py +19 -3
  86. nuitka/code_generation/ConstantCodes.py +5 -0
  87. nuitka/code_generation/Contexts.py +22 -6
  88. nuitka/code_generation/Emission.py +1 -0
  89. nuitka/code_generation/ErrorCodes.py +8 -16
  90. nuitka/code_generation/EvalCodes.py +5 -3
  91. nuitka/code_generation/ExceptionCodes.py +8 -1
  92. nuitka/code_generation/ExpressionCTypeSelectionHelpers.py +1 -0
  93. nuitka/code_generation/FrameCodes.py +5 -3
  94. nuitka/code_generation/FunctionCodes.py +0 -1
  95. nuitka/code_generation/GeneratorCodes.py +3 -3
  96. nuitka/code_generation/GlobalConstants.py +1 -2
  97. nuitka/code_generation/ImportCodes.py +2 -0
  98. nuitka/code_generation/JitCodes.py +44 -0
  99. nuitka/code_generation/ListCodes.py +11 -17
  100. nuitka/code_generation/MatchCodes.py +0 -1
  101. nuitka/code_generation/ModuleCodes.py +2 -1
  102. nuitka/code_generation/Namify.py +0 -1
  103. nuitka/code_generation/NetworkxCodes.py +51 -0
  104. nuitka/code_generation/OperationCodes.py +8 -6
  105. nuitka/code_generation/PackageResourceCodes.py +7 -5
  106. nuitka/code_generation/TensorflowCodes.py +54 -0
  107. nuitka/code_generation/TypeAliasCodes.py +71 -0
  108. nuitka/code_generation/VariableCodes.py +7 -5
  109. nuitka/code_generation/VariableDeclarations.py +1 -0
  110. nuitka/code_generation/c_types/CTypeCLongs.py +0 -1
  111. nuitka/code_generation/c_types/CTypeNuitkaInts.py +0 -1
  112. nuitka/code_generation/c_types/CTypeVoids.py +1 -0
  113. nuitka/code_generation/templates/CodeTemplatesConstants.py +15 -0
  114. nuitka/code_generation/templates/CodeTemplatesExceptions.py +1 -1
  115. nuitka/code_generation/templates/CodeTemplatesIterators.py +0 -1
  116. nuitka/code_generation/templates/CodeTemplatesLoader.py +0 -1
  117. nuitka/code_generation/templates/CodeTemplatesModules.py +4 -1
  118. nuitka/code_generation/templates/CodeTemplatesVariables.py +8 -8
  119. nuitka/code_generation/templates/TemplateDebugWrapper.py +0 -1
  120. nuitka/code_generation/templates_c/HelperOperationComparisonUnicode.c.j2 +4 -0
  121. nuitka/code_generation/templates_c/HelperSlotsLong.c.j2 +9 -7
  122. nuitka/containers/Namedtuples.py +0 -1
  123. nuitka/finalizations/Finalization.py +1 -0
  124. nuitka/finalizations/FinalizeMarkups.py +0 -1
  125. nuitka/freezer/DllDependenciesMacOS.py +60 -13
  126. nuitka/freezer/DllDependenciesPosix.py +0 -1
  127. nuitka/freezer/IncludedDataFiles.py +46 -15
  128. nuitka/freezer/IncludedEntryPoints.py +5 -3
  129. nuitka/freezer/Standalone.py +6 -1
  130. nuitka/importing/ImportCache.py +2 -2
  131. nuitka/importing/ImportResolving.py +80 -78
  132. nuitka/importing/Importing.py +34 -1
  133. nuitka/nodes/AttributeNodesGenerated.py +21 -6
  134. nuitka/nodes/BuiltinComplexNodes.py +1 -0
  135. nuitka/nodes/BuiltinFormatNodes.py +1 -0
  136. nuitka/nodes/BuiltinIteratorNodes.py +5 -3
  137. nuitka/nodes/BuiltinOperationNodeBasesGenerated.py +21 -6
  138. nuitka/nodes/BuiltinRefNodes.py +8 -1
  139. nuitka/nodes/BuiltinVarsNodes.py +0 -1
  140. nuitka/nodes/ChildrenHavingMixins.py +906 -186
  141. nuitka/nodes/CodeObjectSpecs.py +1 -1
  142. nuitka/nodes/ConstantRefNodes.py +38 -0
  143. nuitka/nodes/CtypesNodes.py +0 -1
  144. nuitka/nodes/DictionaryNodes.py +0 -1
  145. nuitka/nodes/ExceptionNodes.py +10 -0
  146. nuitka/nodes/ExpressionBases.py +15 -9
  147. nuitka/nodes/ExpressionBasesGenerated.py +32 -15
  148. nuitka/nodes/FunctionNodes.py +50 -5
  149. nuitka/nodes/HardImportNodesGenerated.py +245 -60
  150. nuitka/nodes/ImportHardNodes.py +27 -13
  151. nuitka/nodes/ImportNodes.py +90 -70
  152. nuitka/nodes/InjectCNodes.py +0 -1
  153. nuitka/nodes/ModuleNodes.py +10 -5
  154. nuitka/nodes/NetworkxNodes.py +45 -0
  155. nuitka/nodes/OperatorNodesUnary.py +1 -0
  156. nuitka/nodes/OsSysNodes.py +0 -1
  157. nuitka/nodes/PackageMetadataNodes.py +0 -1
  158. nuitka/nodes/PackageResourceNodes.py +10 -6
  159. nuitka/nodes/StatementBasesGenerated.py +107 -60
  160. nuitka/nodes/StringConcatenationNodes.py +1 -0
  161. nuitka/nodes/TensorflowNodes.py +38 -0
  162. nuitka/nodes/TypeNodes.py +21 -0
  163. nuitka/nodes/VariableRefNodes.py +1 -0
  164. nuitka/nodes/shapes/BuiltinTypeShapes.py +25 -15
  165. nuitka/optimizations/Optimization.py +7 -6
  166. nuitka/optimizations/OptimizeBuiltinCalls.py +11 -9
  167. nuitka/optimizations/Tags.py +0 -1
  168. nuitka/optimizations/TraceCollections.py +6 -55
  169. nuitka/optimizations/ValueTraces.py +49 -1
  170. nuitka/plugins/PluginBase.py +26 -4
  171. nuitka/plugins/Plugins.py +49 -12
  172. nuitka/plugins/standard/AntiBloatPlugin.py +12 -2
  173. nuitka/plugins/standard/ConsiderPyLintAnnotationsPlugin.py +0 -1
  174. nuitka/plugins/standard/DataFilesPlugin.py +2 -6
  175. nuitka/plugins/standard/DillPlugin.py +3 -3
  176. nuitka/plugins/standard/DllFilesPlugin.py +29 -23
  177. nuitka/plugins/standard/GiPlugin.py +1 -0
  178. nuitka/plugins/standard/ImplicitImports.py +9 -7
  179. nuitka/plugins/standard/MatplotlibPlugin.py +1 -0
  180. nuitka/plugins/standard/OptionsNannyPlugin.py +3 -7
  181. nuitka/plugins/standard/PkgResourcesPlugin.py +0 -1
  182. nuitka/plugins/standard/PmwPlugin.py +10 -9
  183. nuitka/plugins/standard/PySidePyQtPlugin.py +0 -28
  184. nuitka/plugins/standard/TensorflowPlugin.py +1 -0
  185. nuitka/plugins/standard/TorchPlugin.py +1 -0
  186. nuitka/plugins/standard/TrioPlugin.py +1 -0
  187. nuitka/plugins/standard/standard.nuitka-package.config.yml +242 -54
  188. nuitka/reports/CompilationReportReader.py +0 -1
  189. nuitka/reports/Reports.py +49 -5
  190. nuitka/specs/BuiltinParameterSpecs.py +10 -2
  191. nuitka/specs/BuiltinStrOperationSpecs.py +1 -1
  192. nuitka/specs/BuiltinTypeOperationSpecs.py +0 -1
  193. nuitka/specs/HardImportSpecs.py +34 -1
  194. nuitka/specs/ParameterSpecs.py +11 -9
  195. nuitka/tools/environments/Virtualenv.py +0 -1
  196. nuitka/tools/specialize/CTypeDescriptions.py +15 -11
  197. nuitka/tools/specialize/SpecializeC.py +11 -9
  198. nuitka/tools/specialize/SpecializePython.py +57 -30
  199. nuitka/tools/testing/Common.py +24 -7
  200. nuitka/tools/testing/OutputComparison.py +4 -0
  201. nuitka/tools/testing/Pythons.py +0 -1
  202. nuitka/tools/testing/compare_with_cpython/__main__.py +0 -4
  203. nuitka/tools/watch/GitHub.py +4 -1
  204. nuitka/tools/watch/__main__.py +22 -1
  205. nuitka/tree/Building.py +3 -0
  206. nuitka/tree/InternalModule.py +0 -1
  207. nuitka/tree/ReformulationAssertStatements.py +1 -0
  208. nuitka/tree/ReformulationAssignmentStatements.py +26 -3
  209. nuitka/tree/ReformulationClasses3.py +23 -26
  210. nuitka/tree/ReformulationContractionExpressions.py +5 -3
  211. nuitka/tree/ReformulationDictionaryCreation.py +6 -5
  212. nuitka/tree/ReformulationExecStatements.py +8 -6
  213. nuitka/tree/ReformulationFunctionStatements.py +10 -6
  214. nuitka/tree/SourceHandling.py +8 -0
  215. nuitka/tree/TreeHelpers.py +6 -3
  216. nuitka/utils/AppDirs.py +6 -2
  217. nuitka/utils/CStrings.py +1 -1
  218. nuitka/utils/CommandLineOptions.py +0 -1
  219. nuitka/utils/Distributions.py +3 -3
  220. nuitka/utils/Download.py +5 -1
  221. nuitka/utils/Execution.py +6 -3
  222. nuitka/utils/FileOperations.py +62 -35
  223. nuitka/utils/Importing.py +4 -4
  224. nuitka/utils/InstanceCounters.py +1 -0
  225. nuitka/utils/MacOSApp.py +1 -0
  226. nuitka/utils/Shebang.py +1 -0
  227. nuitka/utils/Utils.py +39 -1
  228. nuitka/utils/WindowsFileUsage.py +4 -3
  229. {Nuitka_winsvc-2.1.5.data → Nuitka_winsvc-2.2.1.data}/scripts/nuitka-run.bat +0 -0
  230. {Nuitka_winsvc-2.1.5.data → Nuitka_winsvc-2.2.1.data}/scripts/nuitka.bat +0 -0
  231. {Nuitka_winsvc-2.1.5.dist-info → Nuitka_winsvc-2.2.1.dist-info}/LICENSE.txt +0 -0
  232. {Nuitka_winsvc-2.1.5.dist-info → Nuitka_winsvc-2.2.1.dist-info}/WHEEL +0 -0
  233. {Nuitka_winsvc-2.1.5.dist-info → Nuitka_winsvc-2.2.1.dist-info}/entry_points.txt +0 -0
  234. {Nuitka_winsvc-2.1.5.dist-info → Nuitka_winsvc-2.2.1.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 (Py_ABS(Py_SIZE(operand1_long_object)) <= 1 && Py_ABS(Py_SIZE(operand2_long_object)) <= 1) {
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->ob_digit;
1044
- Py_ssize_t a_digit_count = Py_ABS(Py_SIZE(operand1_long_object));
1045
- bool a_negative = Py_SIZE(operand1_long_object) < 0;
1046
- digit const *b_digits = operand2_long_object->ob_digit;
1047
- Py_ssize_t b_digit_count = Py_ABS(Py_SIZE(operand2_long_object));
1048
- bool b_negative = Py_SIZE(operand2_long_object) < 0;
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
- Py_SET_SIZE(z, -(Py_SIZE(z)));
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 (Py_ABS(Py_SIZE(operand1_long_object)) <= 1 && Py_ABS(Py_SIZE(operand2_long_object)) <= 1) {
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->ob_digit;
1278
- Py_ssize_t a_digit_count = Py_ABS(Py_SIZE(operand1_long_object));
1279
- bool a_negative = Py_SIZE(operand1_long_object) < 0;
1280
- digit const *b_digits = operand2_long_object->ob_digit;
1281
- Py_ssize_t b_digit_count = Py_ABS(Py_SIZE(operand2_long_object));
1282
- bool b_negative = Py_SIZE(operand2_long_object) < 0;
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
- Py_SET_SIZE(z, -(Py_SIZE(z)));
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 (Py_ABS(Py_SIZE(operand1_long_object)) <= 1 && Py_ABS(Py_SIZE(operand2_long_object)) <= 1) {
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->ob_digit;
1520
- Py_ssize_t a_digit_count = Py_ABS(Py_SIZE(operand1_long_object));
1521
- bool a_negative = Py_SIZE(operand1_long_object) < 0;
1522
- digit const *b_digits = operand2_long_object->ob_digit;
1523
- Py_ssize_t b_digit_count = Py_ABS(Py_SIZE(operand2_long_object));
1524
- bool b_negative = Py_SIZE(operand2_long_object) < 0;
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
- Py_SET_SIZE(z, -(Py_SIZE(z)));
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 (Py_ABS(Py_SIZE(operand1_long_object)) <= 1 && Py_ABS(Py_SIZE(operand2_long_object)) <= 1) {
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->ob_digit;
1605
- Py_ssize_t a_digit_count = Py_ABS(Py_SIZE(operand1_long_object));
1606
- bool a_negative = Py_SIZE(operand1_long_object) < 0;
1607
- digit const *b_digits = operand2_long_object->ob_digit;
1608
- Py_ssize_t b_digit_count = Py_ABS(Py_SIZE(operand2_long_object));
1609
- bool b_negative = Py_SIZE(operand2_long_object) < 0;
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
- Py_SET_SIZE(z, -(Py_SIZE(z)));
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 (Py_ABS(Py_SIZE(operand1_long_object)) <= 1 && Py_ABS(Py_SIZE(operand2_long_object)) <= 1) {
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->ob_digit;
1849
- Py_ssize_t a_digit_count = Py_ABS(Py_SIZE(operand1_long_object));
1850
- bool a_negative = Py_SIZE(operand1_long_object) < 0;
1851
- digit const *b_digits = operand2_long_object->ob_digit;
1852
- Py_ssize_t b_digit_count = Py_ABS(Py_SIZE(operand2_long_object));
1853
- bool b_negative = Py_SIZE(operand2_long_object) < 0;
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
- Py_SET_SIZE(z, -(Py_SIZE(z)));
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 (Py_ABS(Py_SIZE(operand1_long_object)) <= 1 && Py_ABS(Py_SIZE(operand2_long_object)) <= 1) {
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->ob_digit;
2101
- Py_ssize_t a_digit_count = Py_ABS(Py_SIZE(operand1_long_object));
2102
- bool a_negative = Py_SIZE(operand1_long_object) < 0;
2103
- digit const *b_digits = operand2_long_object->ob_digit;
2104
- Py_ssize_t b_digit_count = Py_ABS(Py_SIZE(operand2_long_object));
2105
- bool b_negative = Py_SIZE(operand2_long_object) < 0;
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
- Py_SET_SIZE(z, -(Py_SIZE(z)));
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 (Py_ABS(Py_SIZE(operand1_long_object)) <= 1 && (operand2 == 0 ? 0 : 1) <= 1) {
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->ob_digit;
3557
- Py_ssize_t a_digit_count = Py_ABS(Py_SIZE(operand1_long_object));
3558
- bool a_negative = Py_SIZE(operand1_long_object) < 0;
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
- Py_SET_SIZE(z, -(Py_SIZE(z)));
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 (Py_ABS(Py_SIZE(operand1_long_object)) <= 1 && (operand2 == 0 ? 0 : 1) <= 1) {
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->ob_digit;
3637
- Py_ssize_t a_digit_count = Py_ABS(Py_SIZE(operand1_long_object));
3638
- bool a_negative = Py_SIZE(operand1_long_object) < 0;
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
- Py_SET_SIZE(z, -(Py_SIZE(z)));
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 >= 0x300
63
- PyLongObject *result;
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
- result = (PyLongObject *)PyObject_MALLOC(offsetof(PyLongObject, ob_digit) + size * sizeof(digit));
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
- Py_SET_SIZE(result, size);
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
- Py_SET_SIZE(result, -1);
149
+ Nuitka_LongSetSignNegative(result);
115
150
  }
116
151
 
117
- result->ob_digit[0] = (digit)abs_ival;
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
- Py_SIZE(result) = -2;
164
+ Nuitka_LongSetSignNegative(result);
129
165
  }
130
166
 
131
- result->ob_digit[0] = (digit)(abs_ival & PyLong_MASK);
132
- result->ob_digit[1] = (digit)(abs_ival >> PyLong_SHIFT);
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
- Py_SET_SIZE(result, negative ? -ndigits : ndigits);
189
+ Nuitka_LongSetDigitSizeAndNegative(result, ndigits, negative);
152
190
 
153
- digit *d = result->ob_digit;
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
- Py_SET_SIZE(result, negative ? -1 : 1);
257
+ Nuitka_LongSetSign(result, !negative);
217
258
 
218
- result->ob_digit[0] = (digit)abs_ival;
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
- Py_SIZE(result) = negative ? -2 : 2;
278
+ if (negative) {
279
+ Nuitka_LongSetSignNegative(result);
280
+ }
281
+
282
+ digit *digits = Nuitka_LongGetDigitPointer(result);
237
283
 
238
- result->ob_digit[0] = (digit)(abs_ival & PyLong_MASK);
239
- result->ob_digit[1] = (digit)(abs_ival >> PyLong_SHIFT);
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
- Py_SET_SIZE(*value, negative ? -ndigits : ndigits);
307
+ Nuitka_LongSetDigitSizeAndNegative((PyLongObject *)*value, ndigits, negative);
262
308
 
263
- digit *d = ((PyLongObject *)(*value))->ob_digit;
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 = &result->ob_digit[0];
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
- Py_SET_SIZE(result, Py_SIZE(result) - 1);
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
- Py_SET_SIZE(left, i + 1);
467
+ Nuitka_LongSetDigitSizeAndNegative((PyLongObject *)left, i + 1, false);
421
468
  } else {
422
- Py_SET_SIZE(left, i);
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 = &result->ob_digit[0];
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
- Py_SET_SIZE(result, (sign < 0) ? -i : i);
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
- long ival = MEDIUM_VALUE(result);
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
- Py_SET_SIZE(left, (sign < 0) ? -i : i);
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
- long ival = MEDIUM_VALUE(left);
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
- Py_ssize_t i = Py_SIZE(value);
17
+ assert(PyLong_Check(value));
18
+
19
+ Py_ssize_t digits_count = Nuitka_LongGetDigitSize(value);
18
20
 
19
- if (i == 0) {
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
- if (i == 1) {
26
- return long_value->ob_digit[0];
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
- bool is_negative = i < 0;
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) | long_value->ob_digit[i];
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) {