-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
gh-142108: Document Decimal formatting behavior differences #142117
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
Conversation
StanFromIreland
left a comment
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.
You have multiple different changes mixed together, please split it out.
skirpichev
left a comment
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.
I'll mark this a draft. Sorry, but current approach seems unacceptable for me.
PS: Please also don't alter commit history in any way (force-pushes, etc).
| .. c:function:: PyObject* PyDescr_NewMember(PyTypeObject *type, struct PyMemberDef *meth) | ||
| .. c:var:: PyTypeObject PyMemberDescr_Type |
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.
Changes in Doc/c-api/ are not related to this pr, please revert.
| * When using ``__format__`` (f-strings, ``format()``, ``str.format()``), | ||
| Decimal formats with maximum precision only when precision is **omitted** |
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.
This is already documented, please revert. Also, the whole section of documentation is about string formatting, it's pointless to say that you are using __format__().
| * When using ``%`` formatting (old-style string formatting with the ``%`` operator), | ||
| Decimal values are first converted to :class:`float`, which may result in |
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.
- This note not belongs to this section, it's about printf-like formatting.
- In the issue thread it was explained, that there is nothing special about Decimal's here. If we have to document something, it should be about behavior of printf-like formatting for non-builtin types.
|
Apologies for the confusion—I had an out-of-sync branch that mixed commits from multiple PRs. After reviewing the feedback, I realize:
Closing this PR. I'll discuss on the issue thread whether any documentation changes are still needed before opening a fresh PR. Thanks for the review. |
This PR clarifies how
Decimalbehaves differently when formatted using__format__(f-strings,format(),str.format()) versus%formatting (old-style string formatting).Changes:
__format__: Decimal uses maximum precision only when precision is omitted in f/e/g format types; explicit precision is respected%formatting: Decimal values are converted tofloatfirst, resulting in potential precision lossDocumentation preview: (will be auto-generated)
Fixes #142108
printf-style formatting docs for non-built-in types #142108📚 Documentation preview 📚: https://cpython-previews--142117.org.readthedocs.build/