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-131885: Use positional-only markers for the ``decimal`` module by donbarbos · Pull Request #131990 · python/cpython

Conversation

@donbarbos

@donbarbos donbarbos commented Apr 1, 2025 •
edited by skirpichev
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

also noticed a missing default value num='0' for create_decimal

  • Issue: Update function signatures to use * and / as needed #131885

📚 Documentation preview 📚: https://cpython-previews--131990.org.readthedocs.build/en/131990/library/decimal.html#decimal-objects

Sorry, something went wrong.

Uh oh!

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

Edgarruiz856 reacted with rocket emoji
All reactions
  • 🚀 1 reaction
@donbarbos
Add / for decimal.Context methods docs
e167670
@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 added this to Docs PRs Apr 1, 2025
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Apr 1, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Apr 1, 2025
Update function signatures to use * and / as needed #131885
Open
4 of 5 tasks
@donbarbos donbarbos changed the title gh-131885: Add / for decimal.Context methods docs gh-131885: Document / for decimal.Context methods Apr 1, 2025
skirpichev
skirpichev reviewed Apr 2, 2025
View reviewed changes

@skirpichev skirpichev 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.

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.

Sorry, something went wrong.

Uh oh!

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

All reactions
@donbarbos

donbarbos commented Apr 2, 2025 •
edited
Loading

Uh oh!

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

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

All reactions

Sorry, something went wrong.

Uh oh!

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

@python-cla-bot

This comment was marked as resolved.

Sign in to view
@skirpichev
skirpichev self-requested a review August 13, 2025 03:02
skirpichev
skirpichev approved these changes Aug 13, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting core review and removed awaiting review labels Aug 13, 2025
@skirpichev
skirpichev requested a review from AA-Turner August 13, 2025 03:09
@skirpichev

skirpichev commented Aug 13, 2025

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?

All reactions

Sorry, something went wrong.

Uh oh!

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

@donbarbos

donbarbos commented Aug 13, 2025

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

All reactions

Sorry, something went wrong.

Uh oh!

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

@skirpichev

skirpichev commented Aug 13, 2025

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.

donbarbos reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@skirpichev skirpichev added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels Aug 13, 2025
@donbarbos
Document rest docs
a990abf
@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

donbarbos commented Aug 13, 2025

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)

All reactions

Sorry, something went wrong.

Uh oh!

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

@skirpichev

skirpichev commented Aug 13, 2025

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

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

skirpichev
skirpichev approved these changes Aug 13, 2025
View reviewed changes

@skirpichev skirpichev 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.

Yes, I think all is fixed.

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

Sorry, something went wrong.

Uh oh!

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

donbarbos reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@donbarbos

donbarbos commented Aug 13, 2025

Copy link
Copy Markdown
Contributor Author

Thank you for review

All reactions

Sorry, something went wrong.

Uh oh!

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

@skirpichev skirpichev mentioned this pull request Aug 17, 2025
gh-117056: fix discrepancy in _decimal/_pydecimal public signatures #137697
Closed
AA-Turner
AA-Turner approved these changes Aug 18, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Aug 18, 2025
@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
@miss-islington-app

miss-islington-app Bot commented Aug 18, 2025

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.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the awaiting merge label Aug 18, 2025
@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
@donbarbos @miss-islington
pythongh-131885: Use positional-only markers for the decimal modu…
1501a7f
…le (pythonGH-131990)

(cherry picked from commit 043f251)

Co-authored-by: Semyon Moroz <[email protected]>
@miss-islington-app

miss-islington-app Bot commented Aug 18, 2025

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

Sorry, something went wrong.

Uh oh!

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

@bedevere-app

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.

All reactions

Sorry, something went wrong.

Uh oh!

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

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

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.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Aug 18, 2025
AA-Turner pushed a commit to AA-Turner/cpython that referenced this pull request Aug 18, 2025
@donbarbos @AA-Turner
[3.13] pythongh-131885: Use positional-only markers for the ``decimal…
a599f4d
…`` module (pythonGH-131990)

(cherry picked from commit 043f251)

Co-authored-by: Semyon Moroz <[email protected]>
AA-Turner added a commit that referenced this pull request Aug 18, 2025
@AA-Turner @donbarbos
[3.13] gh-131885: Use positional-only markers for the decimal mod…
135e834
…ule (GH-131990) (#137904)

Co-authored-by: Semyon Moroz <[email protected]>
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
@donbarbos @Agent-Hellboy
pythongh-131885: Use positional-only markers for the decimal modu…
a1a7a1b
…le (python#131990)
hugovk pushed a commit that referenced this pull request Sep 11, 2025
@miss-islington @donbarbos
[3.14] gh-131885: Use positional-only markers for the decimal mod…
39e024d
…ule (GH-131990) (#137902)

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

Reviewers

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

docs Documentation in the Doc dir skip news

Projects

Docs PRs
Status: Done

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

@donbarbos @skirpichev @AA-Turner
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.