FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-131885: Use positional-only markers for the ``decimal`` module by donbarbos · Pull Request #131990 · python/cpython · GitHub

/ cpython Public

gh-131885: Use positional-only markers for the decimal module - #131990

Merged
AA-Turner merged 2 commits into
python:mainfrom
donbarbos:issue-131885-decimal
Aug 18, 2025
Merged

gh-131885: Use positional-only markers for the decimal module#131990
AA-Turner merged 2 commits into
python:mainfrom
donbarbos:issue-131885-decimal

Conversation

donbarbos commented Apr 1, 2025
edited by skirpichev
Loading

Copy link
Copy Markdown
Contributor

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

skirpichev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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 commented Apr 2, 2025
edited
Loading

Copy link
Copy Markdown
Contributor Author

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

This comment was marked as resolved.

skirpichev self-requested a review August 13, 2025 03:02

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
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

Copy link
Copy Markdown
Member

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 added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Aug 13, 2025
skirpichev changed the title gh-131885: Document / for decimal.Context methods gh-131885: update function signatures with / in decimal module Aug 13, 2025
skirpichev self-requested a review August 13, 2025 07:09

Copy link
Copy Markdown
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)

Copy link
Copy Markdown
Member

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

skirpichev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, I think all is fixed.

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

Copy link
Copy Markdown
Contributor Author

Thank you for review

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 merged commit 043f251 into python:main Aug 18, 2025
31 checks passed

Copy link
Copy Markdown

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 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>

Copy link
Copy Markdown

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 Bot commented Aug 18, 2025

Copy link
Copy Markdown

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

bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 18, 2025

bedevere-app Bot commented Aug 18, 2025

Copy link
Copy Markdown

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

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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL