gh-131885: Use positional-only markers for the decimal module#131990
gh-131885: Use positional-only markers for the decimal module#131990AA-Turner merged 2 commits intopython:mainfrom
decimal module#131990Conversation
/ for decimal.Context methods docs/ for decimal.Context methods
skirpichev
left a comment
There was a problem hiding this comment.
Note that signatures for pure-Python versions differ wrt C-coded extension:
>>> import _decimal, _pydecimal
>>> help(_decimal.getcontext().plus)
Help on built-in function plus:
plus(x, /) method of decimal.Context instance
Plus corresponds to the unary prefix plus operator in Python, but applies
the context to the result.
>>> help(_pydecimal.getcontext().plus)
Help on method plus:
plus(a) method of decimal.Context instance
Plus corresponds to unary prefix plus in Python.
The operation is evaluated using the same rules as add; the
operation plus(a) is calculated as add('0', a) where the '0'
has the same exponent as the operand.
>>> ExtendedContext.plus(Decimal('1.3'))
Decimal('1.3')
>>> ExtendedContext.plus(Decimal('-1.3'))
Decimal('-1.3')
>>> ExtendedContext.plus(-1)
Decimal('-1')
If we are going to add slashes - pure-Python version should be fixed. Or vice-versa.
|
although I'm not a fan of using and I think here we will need ping more core members |
This comment was marked as resolved.
This comment was marked as resolved.
|
Sorry for a delay, it's look ok for me. Would you like to fix the rest of the decimal sphinx docs in another pr? |
Sorry, but I don't understand what you mean by "rest of the decimal sphinx docs". Do you mean some new functions like |
For example, setcontext() function: >>> import _decimal, _pydecimal, inspect
>>> inspect.signature(_decimal.setcontext)
<Signature (context, /)>
>>> inspect.signature(_pydecimal.setcontext)
<Signature (context)>You should also check Decimal methods. |
/ for decimal.Context methods/ in decimal module
|
I also thought that there is a lot of For example, |
|
Sphinx docs don't include self arguments, so we omit leading |
skirpichev
left a comment
There was a problem hiding this comment.
Yes, I think all is fixed.
There is an odd description of the round() builtin, but it probably should be fixed separately.
|
Thank you for review |
/ in decimal moduledecimal module
|
Thanks @donbarbos for the PR, and @AA-Turner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…le (pythonGH-131990) (cherry picked from commit 043f251) Co-authored-by: Semyon Moroz <[email protected]>
|
Sorry, @donbarbos and @AA-Turner, I could not cleanly backport this to |
|
GH-137902 is a backport of this pull request to the 3.14 branch. |
|
GH-137904 is a backport of this pull request to the 3.13 branch. |
…`` module (pythonGH-131990) (cherry picked from commit 043f251) Co-authored-by: Semyon Moroz <[email protected]>
…ule (GH-131990) (#137904) Co-authored-by: Semyon Moroz <[email protected]>
…ule (GH-131990) (#137902) Co-authored-by: Semyon Moroz <[email protected]>
also noticed a missing default value
num='0'forcreate_decimal*and/as needed #131885📚 Documentation preview 📚: https://cpython-previews--131990.org.readthedocs.build/en/131990/library/decimal.html#decimal-objects