Skip to content

Conversation

@donbarbos
Copy link
Contributor

@donbarbos donbarbos commented Apr 1, 2025

@bedevere-app bedevere-app bot added awaiting review docs Documentation in the Doc dir skip news labels Apr 1, 2025
@github-project-automation github-project-automation bot moved this to Todo in Docs PRs Apr 1, 2025
@donbarbos donbarbos changed the title gh-131885: Add / for decimal.Context methods docs gh-131885: Document / for decimal.Context methods Apr 1, 2025
Copy link
Contributor

@skirpichev skirpichev left a comment

Choose a reason for hiding this comment

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

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.

@donbarbos
Copy link
Contributor Author

donbarbos commented Apr 2, 2025

although I'm not a fan of using /, I think it will be easier to make the only positional arguments in pure-Python implementation

and I think here we will need ping more core members

@python-cla-bot

This comment was marked as resolved.

@skirpichev skirpichev self-requested a review August 13, 2025 03:02
@skirpichev
Copy link
Contributor

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?

@donbarbos
Copy link
Contributor Author

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 from_number?
If so, then it is probably really worth doing this in a separate PR so that there is still the possibility for bacports here, although maybe it is possible to make backports just more carefully and manually

@skirpichev
Copy link
Contributor

Sorry, but I don't understand what you mean by "rest of the decimal sphinx docs".

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.

@skirpichev skirpichev added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Aug 13, 2025
@skirpichev skirpichev changed the title gh-131885: Document / for decimal.Context methods gh-131885: update function signatures with / in decimal module Aug 13, 2025
@skirpichev skirpichev self-requested a review August 13, 2025 07:09
@donbarbos
Copy link
Contributor Author

I also thought that there is a lot of / before arguments, but documenting it doesn't seem useful unless I'm missing something

For example, fma method has next signature: fma(self, /, other, third, context=None)

@skirpichev
Copy link
Contributor

Sphinx docs don't include self arguments, so we omit leading /.

Copy link
Contributor

@skirpichev skirpichev left a comment

Choose a reason for hiding this comment

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

Yes, I think all is fixed.

There is an odd description of the round() builtin, but it probably should be fixed separately.

@donbarbos
Copy link
Contributor Author

Thank you for review

@AA-Turner AA-Turner changed the title gh-131885: update function signatures with / in decimal module gh-131885: Use positional-only markers for the decimal module Aug 18, 2025
@AA-Turner AA-Turner merged commit 043f251 into python:main Aug 18, 2025
31 checks passed
@miss-islington-app
Copy link

Thanks @donbarbos for the PR, and @AA-Turner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Aug 18, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 18, 2025
…le (pythonGH-131990)

(cherry picked from commit 043f251)

Co-authored-by: Semyon Moroz <donbarbos@proton.me>
@miss-islington-app
Copy link

Sorry, @donbarbos and @AA-Turner, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 043f251154fbac9a4e66243b8cae220a284ed1c4 3.13

@bedevere-app
Copy link

bedevere-app bot commented Aug 18, 2025

GH-137902 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Aug 18, 2025
@bedevere-app
Copy link

bedevere-app bot commented Aug 18, 2025

GH-137904 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Aug 18, 2025
AA-Turner pushed a commit to AA-Turner/cpython that referenced this pull request Aug 18, 2025
…`` module (pythonGH-131990)

(cherry picked from commit 043f251)

Co-authored-by: Semyon Moroz <donbarbos@proton.me>
AA-Turner added a commit that referenced this pull request Aug 18, 2025
…ule (GH-131990) (#137904)

Co-authored-by: Semyon Moroz <donbarbos@proton.me>
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
hugovk pushed a commit that referenced this pull request Sep 11, 2025
…ule (GH-131990) (#137902)

Co-authored-by: Semyon Moroz <donbarbos@proton.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants