Add numeric fast paths for binary arithmetic

Merged
JA
25d ago
+450-3

Binary addition, subtraction and multiplication currently pop operands and set up cleanup guards before dispatching by type. Handle immediate int/int, float/float and mixed int/float pairs directly on the operand stack, avoiding those guards and general type dispatch.

Overflowing integer results promote directly to BigInt using the existing i128 conversion helper. Existing BigInt operands and other types retain the general arithmetic path.

Validation: numeric arithmetic tests pass with and without ref-count-return, covering overflow, BigInt operands, mixed numeric types, booleans, sequence fallbacks and signed zero. Formatting and diff checks pass. Performance has not been benchmarked.


Summary by cubic

Adds stack fast paths for binary arithmetic and numeric comparisons on immediate int/float operands, covering +, -, *, /, //, %, their in-place forms, and ==, !=, <, <=, >, >=. These avoid reference-count guards and general type dispatch.

  • Int overflow promotes to BigInt through the existing i128 conversion helper, including subtraction; zero divisors keep the general error path.
  • Non-numeric operands (BigInt, sequences, containers) and non-numeric comparison operators keep the general paths so in-place operators still mutate in place.