GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-73487: Convert _decimal to use Argument Clinic (part 3) by skirpichev · Pull Request #137844 · python/cpython

Conversation

@skirpichev

@skirpichev skirpichev commented Aug 16, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: decimal: Use Argument Clinic #73487

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@skirpichev
skirpichev requested review from AA-Turner and serhiy-storchaka August 16, 2025 05:22
@bedevere-app bedevere-app Bot mentioned this pull request Aug 16, 2025
decimal: Use Argument Clinic #73487
Closed
@skirpichev skirpichev added the skip news label Aug 16, 2025
@skirpichev
skirpichev force-pushed the ac-decimal/73487-pt3 branch 2 times, most recently from 04b5daf to 91d1402 Compare August 16, 2025 07:59
@skirpichev skirpichev added the topic-argument-clinic label Aug 16, 2025
@skirpichev
skirpichev force-pushed the ac-decimal/73487-pt3 branch from 91d1402 to 911c957 Compare August 17, 2025 16:50
@skirpichev
pythongh-73487: Convert _decimal to use Argument Clinic (part 3)
bbdd366
@skirpichev
skirpichev force-pushed the ac-decimal/73487-pt3 branch from 911c957 to bbdd366 Compare August 18, 2025 13:43
@skirpichev
skirpichev marked this pull request as ready for review August 18, 2025 13:56
@bedevere-app bedevere-app Bot added the awaiting review label Aug 18, 2025
@skirpichev

skirpichev commented Aug 18, 2025

Copy link
Copy Markdown
Member Author

Docstrings diff

--- ref.txt 2025-08-18 17:44:04.254784483 +0300
+++ patch.txt   2025-08-18 17:10:44.875040300 +0300
@@ -582,12 +582,14 @@
      |      so this operation returns its argument unchanged.
      |
      |  compare(self, /, other, context=None)
-     |      Compare self to other.  Return a decimal value:
+     |      Compare self to other.
      |
-     |      a or b is a NaN ==> Decimal('NaN')
-     |      a < b           ==> Decimal('-1')
-     |      a == b          ==> Decimal('0')
-     |      a > b           ==> Decimal('1')
+     |      Return a decimal value:
+     |
+     |          a or b is a NaN ==> Decimal('NaN')
+     |          a < b           ==> Decimal('-1')
+     |          a == b          ==> Decimal('0')
+     |          a > b           ==> Decimal('1')
      |
      |  compare_signal(self, /, other, context=None)
      |      Identical to compare, except that all NaNs signal.
@@ -651,13 +653,16 @@
      |      exactly.
      |
      |  exp(self, /, context=None)
-     |      Return the value of the (natural) exponential function e**x at the given
-     |      number.  The function always uses the ROUND_HALF_EVEN mode and the result
-     |      is correctly rounded.
+     |      Return the value of the (natural) exponential function e**x.
+     |
+     |      The function always uses the ROUND_HALF_EVEN mode and the result is
+     |      correctly rounded.
      |
      |  fma(self, /, other, third, context=None)
-     |      Fused multiply-add.  Return self*other+third with no rounding of the
-     |      intermediate product self*other.
+     |      Fused multiply-add.
+     |
+     |      Return self*other+third with no rounding of the intermediate product
+     |      self*other.
      |
      |          >>> Decimal(2).fma(3, 5)
      |          Decimal('11')
@@ -680,9 +685,9 @@
      |      otherwise.
      |
      |  is_normal(self, /, context=None)
-     |      Return True if the argument is a normal finite non-zero number with an
-     |      adjusted exponent greater than or equal to Emin. Return False if the
-     |      argument is zero, subnormal, infinite or a NaN.
+     |      Return True if the argument is a normal number and False otherwise.
+     |
+     |      Normal number is a finite nonzero number, which is not subnormal.
      |
      |  is_qnan(self, /)
      |      Return True if the argument is a quiet NaN, and False otherwise.
@@ -695,27 +700,33 @@
      |      Return True if the argument is a signaling NaN and False otherwise.
      |
      |  is_subnormal(self, /, context=None)
-     |      Return True if the argument is subnormal, and False otherwise. A number is
-     |      subnormal if it is non-zero, finite, and has an adjusted exponent less
-     |      than Emin.
+     |      Return True if the argument is subnormal, and False otherwise.
+     |
+     |      A number is subnormal if it is non-zero, finite, and has an adjusted
+     |      exponent less than Emin.
      |
      |  is_zero(self, /)
      |      Return True if the argument is a (positive or negative) zero and False
      |      otherwise.
      |
      |  ln(self, /, context=None)
-     |      Return the natural (base e) logarithm of the operand. The function always
-     |      uses the ROUND_HALF_EVEN mode and the result is correctly rounded.
+     |      Return the natural (base e) logarithm of the operand.
+     |
+     |      The function always uses the ROUND_HALF_EVEN mode and the result is
+     |      correctly rounded.
      |
      |  log10(self, /, context=None)
-     |      Return the base ten logarithm of the operand. The function always uses the
-     |      ROUND_HALF_EVEN mode and the result is correctly rounded.
+     |      Return the base ten logarithm of the operand.
+     |
+     |      The function always uses the ROUND_HALF_EVEN mode and the result is
+     |      correctly rounded.
      |
      |  logb(self, /, context=None)
-     |      For a non-zero number, return the adjusted exponent of the operand as a
-     |      Decimal instance.  If the operand is a zero, then Decimal('-Infinity') is
-     |      returned and the DivisionByZero condition is raised. If the operand is
-     |      an infinity then Decimal('Infinity') is returned.
+     |      Return the adjusted exponent of the operand as a Decimal instance.
+     |
+     |      If the operand is a zero, then Decimal('-Infinity') is returned and the
+     |      DivisionByZero condition is raised. If the operand is an infinity then
+     |      Decimal('Infinity') is returned.
      |
      |  logical_and(self, /, other, context=None)
      |      Return the digit-wise 'and' of the two (logical) operands.
@@ -727,46 +738,47 @@
      |      Return the digit-wise 'or' of the two (logical) operands.
      |
      |  logical_xor(self, /, other, context=None)
-     |      Return the digit-wise 'exclusive or' of the two (logical) operands.
+     |      Return the digit-wise 'xor' of the two (logical) operands.
      |
      |  max(self, /, other, context=None)
-     |      Maximum of self and other.  If one operand is a quiet NaN and the other is
-     |      numeric, the numeric operand is returned.
+     |      Maximum of self and other.
+     |
+     |      If one operand is a quiet NaN and the other is numeric, the numeric
+     |      operand is returned.
      |
      |  max_mag(self, /, other, context=None)
-     |      Similar to the max() method, but the comparison is done using the absolute
-     |      values of the operands.
+     |      As the max() method, but compares the absolute values of the operands.
      |
      |  min(self, /, other, context=None)
-     |      Minimum of self and other. If one operand is a quiet NaN and the other is
-     |      numeric, the numeric operand is returned.
+     |      Minimum of self and other.
+     |
+     |      If one operand is a quiet NaN and the other is numeric, the numeric
+     |      operand is returned.
      |
      |  min_mag(self, /, other, context=None)
-     |      Similar to the min() method, but the comparison is done using the absolute
-     |      values of the operands.
+     |      As the min() method, but compares the absolute values of the operands.
      |
      |  next_minus(self, /, context=None)
-     |      Return the largest number representable in the given context (or in the
-     |      current default context if no context is given) that is smaller than the
-     |      given operand.
+     |      Returns the largest representable number smaller than itself.
      |
      |  next_plus(self, /, context=None)
-     |      Return the smallest number representable in the given context (or in the
-     |      current default context if no context is given) that is larger than the
-     |      given operand.
+     |      Returns the smallest representable number larger than itself.
      |
      |  next_toward(self, /, other, context=None)
+     |      Returns the number closest to self, in the direction towards other.
+     |
      |      If the two operands are unequal, return the number closest to the first
      |      operand in the direction of the second operand.  If both operands are
      |      numerically equal, return a copy of the first operand with the sign set
      |      to be the same as the sign of the second operand.
      |
      |  normalize(self, /, context=None)
-     |      Normalize the number by stripping the rightmost trailing zeros and
-     |      converting any result equal to Decimal('0') to Decimal('0e0').  Used
-     |      for producing canonical values for members of an equivalence class.
-     |      For example, Decimal('32.100') and Decimal('0.321000e+2') both normalize
-     |      to the equivalent value Decimal('32.1').
+     |      Normalize the number by stripping trailing 0s
+     |
+     |      This also change anything equal to 0 to 0e0.  Used for producing
+     |      canonical values for members of an equivalence class.  For example,
+     |      Decimal('32.100') and Decimal('0.321000e+2') both normalize to
+     |      the equivalent value Decimal('32.1').
      |
      |  number_class(self, /, context=None)
      |      Return a string describing the class of the operand.
@@ -819,23 +831,25 @@
      |      all its arithmetic. Included for compatibility with the specification.
      |
      |  remainder_near(self, /, other, context=None)
-     |      Return the remainder from dividing self by other.  This differs from
-     |      self % other in that the sign of the remainder is chosen so as to minimize
-     |      its absolute value. More precisely, the return value is self - n * other
-     |      where n is the integer nearest to the exact value of self / other, and
-     |      if two integers are equally near then the even one is chosen.
+     |      Return the remainder from dividing self by other.
+     |
+     |      This differs from self % other in that the sign of the remainder is
+     |      chosen so as to minimize its absolute value. More precisely, the return
+     |      value is self - n * other where n is the integer nearest to the exact
+     |      value of self / other, and if two integers are equally near then the
+     |      even one is chosen.
      |
      |      If the result is zero then its sign will be the sign of self.
      |
      |  rotate(self, /, other, context=None)
-     |      Return the result of rotating the digits of the first operand by an amount
-     |      specified by the second operand.  The second operand must be an integer in
-     |      the range -precision through precision. The absolute value of the second
-     |      operand gives the number of places to rotate. If the second operand is
-     |      positive then rotation is to the left; otherwise rotation is to the right.
-     |      The coefficient of the first operand is padded on the left with zeros to
-     |      length precision if necessary. The sign and exponent of the first operand are
-     |      unchanged.
+     |      Returns a rotated copy of self's digits, value-of-other times.
+     |
+     |      The second operand must be an integer in the range -precision through
+     |      precision. The absolute value of the second operand gives the number of
+     |      places to rotate. If the second operand is positive then rotation is to
+     |      the left; otherwise rotation is to the right.  The coefficient of the
+     |      first operand is padded on the left with zeros to length precision if
+     |      necessary. The sign and exponent of the first operand are unchanged.
      |
      |  same_quantum(self, /, other, context=None)
      |      Test whether self and other have the same exponent or both are NaN.
@@ -846,22 +860,25 @@
      |      exactly.
      |
      |  scaleb(self, /, other, context=None)
-     |      Return the first operand with the exponent adjusted the second.  Equivalently,
-     |      return the first operand multiplied by 10**other. The second operand must be
-     |      an integer.
+     |      Return the first operand with the exponent adjusted the second.
+     |
+     |      Equivalently, return the first operand multiplied by 10**other. The
+     |      second operand must be an integer.
      |
      |  shift(self, /, other, context=None)
-     |      Return the result of shifting the digits of the first operand by an amount
-     |      specified by the second operand.  The second operand must be an integer in
-     |      the range -precision through precision. The absolute value of the second
-     |      operand gives the number of places to shift. If the second operand is
-     |      positive, then the shift is to the left; otherwise the shift is to the
-     |      right. Digits shifted into the coefficient are zeros. The sign and exponent
-     |      of the first operand are unchanged.
+     |      Returns a shifted copy of self's digits, value-of-other times.
+     |
+     |      The second operand must be an integer in the range -precision through
+     |      precision. The absolute value of the second operand gives the number
+     |      of places to shift. If the second operand is positive, then the shift
+     |      is to the left; otherwise the shift is to the right. Digits shifted
+     |      into the coefficient are zeros. The sign and exponent of the first
+     |      operand are unchanged.
      |
      |  sqrt(self, /, context=None)
-     |      Return the square root of the argument to full precision. The result is
-     |      correctly rounded using the ROUND_HALF_EVEN rounding mode.
+     |      Return the square root of the argument to full precision.
+     |
+     |      The result is correctly rounded using the ROUND_HALF_EVEN rounding mode.
      |
      |  to_eng_string(self, /, context=None)
      |      Convert to an engineering-type string.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AA-Turner
AA-Turner approved these changes Aug 18, 2025
View reviewed changes
Comment thread Modules/_decimal/_decimal.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_decimal/_decimal.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_decimal/_decimal.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_decimal/_decimal.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_decimal/_decimal.c
module _decimal
class _decimal.Decimal "PyObject *" "&dec_spec"
class _decimal.Context "PyObject *" "&ctx_spec"
class _decimal.Context "PyObject *" "&context_spec"

@AA-Turner AA-Turner Aug 18, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why rename?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@skirpichev skirpichev Aug 19, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's how actually spec variable named. Mostly useful for search now.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Aug 18, 2025
@AA-Turner

AA-Turner commented Aug 18, 2025

Copy link
Copy Markdown
Member

The docstring changes all look reasonable to me.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka
serhiy-storchaka approved these changes Aug 18, 2025
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with @AA-Turner's suggestions. 👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Modules/_decimal/_decimal.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_decimal/_decimal.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_decimal/_decimal.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev @AA-Turner
Apply suggestions from code review
05c6041
Co-authored-by: Adam Turner <[email protected]>
@skirpichev
skirpichev force-pushed the ac-decimal/73487-pt3 branch from f5970f8 to 05c6041 Compare August 19, 2025 01:06
@skirpichev
address review: use aliases in signatures
7a9887d
@skirpichev

skirpichev commented Aug 19, 2025

Copy link
Copy Markdown
Member Author

Next step: #137931

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AA-Turner
AA-Turner merged commit 9cb9130 into python:main Aug 19, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Aug 19, 2025
@skirpichev
skirpichev deleted the ac-decimal/73487-pt3 branch August 19, 2025 08:33
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
@skirpichev @AA-Turner @Agent-Hellboy
pythongh-73487: Convert _decimal to use Argument Clinic (part 3) (p…
0414eec
…ython#137844)

Co-authored-by: Adam Turner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes
@AA-Turner AA-Turner AA-Turner approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news topic-argument-clinic

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@skirpichev @AA-Turner @serhiy-storchaka
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.