Skip to content

gh-131885: Document / for decimal.Context methods #131990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

donBarbos
Copy link
Contributor

@donBarbos donBarbos commented Apr 1, 2025

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


📚 Documentation preview 📚: https://cpython-previews--131990.org.readthedocs.build/

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

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

python-cla-bot bot commented Apr 6, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants