[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-07 Thread Eric V. Smith
Eric V. Smith added the comment: I think your option 2 makes the most sense. -- ___ Python tracker ___ ___ Python-bugs-list

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-07 Thread Mark Dickinson
Mark Dickinson added the comment: Christian Heimes pointed out in the PR discussion that we can't simply modify libmpdec, since some vendors unbundle the mpdecimal library. So some options are: 0. Do nothing. 1. Request that this feature to be added upstream, so that it eventually makes

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-06 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: rhettinger -> ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-06 Thread Mark Dickinson
Mark Dickinson added the comment: > It looks like quite similar changes have already been made: Yes, I think this isn't something that needs to be resolved for this issue, but it is something we need to think about. (Though perhaps the resolution is just "Don't worry about it until we need

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-06 Thread Mark Dickinson
Change by Mark Dickinson : -- keywords: +patch pull_requests: +27692 stage: -> patch review pull_request: https://github.com/python/cpython/pull/29438 ___ Python tracker ___

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-06 Thread Nikita Sobolev
Nikita Sobolev added the comment: > We do need to think about the implications of making local changes to our > copy of the externally-maintained libmpdec library, though. It looks like quite similar changes have already been made:

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-06 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- resolution: duplicate -> stage: resolved -> status: closed -> open superseder: Add underscore as a decimal separator for string formatting -> ___ Python tracker

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-06 Thread Mark Dickinson
Mark Dickinson added the comment: Serhiy: this is not a duplicate of #43624. That issue is about underscores in the *fractional* part of a (float / complex / Decimal) number, and the changes to the formatting mini-language syntax that would be necessary to support that. This issue is simply

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This is a duplicate of issue43624. It was also discussed in Discuss. -- resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> Add underscore as a decimal separator for string formatting

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-05 Thread Sander Bollen
Sander Bollen added the comment: Thanks for looking into this so swiftly! As a user, I have found PEP515 to be worded a little ambiguously with regards to formatting using underscores as thousands separators. While it enumerates a collection of types as far as the constructor is concerned,

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-05 Thread Mark Dickinson
Change by Mark Dickinson : -- nosy: -mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-04 Thread Raymond Hettinger
Change by Raymond Hettinger : -- nosy: +serhiy.storchaka ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-04 Thread Mark Dickinson
Mark Dickinson added the comment: > whether Decimal should extend beyond the specification in this case We already go way beyond the original specification for string formatting. The spec doesn't go further than specifying to-scientific-string and to-engineering-string, neither of which

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-04 Thread Raymond Hettinger
Raymond Hettinger added the comment: Tim, do you have any thoughts on whether Decimal should extend beyond the specification in this case? -- assignee: -> rhettinger nosy: +rhettinger, tim.peters ___ Python tracker

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-04 Thread Nikita Sobolev
Nikita Sobolev added the comment: More context Original commit with `_` format: https://github.com/python/cpython/commit/89e1b1aae0775341735de6bc5e97b3c1e9cea0fa -- ___ Python tracker

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-04 Thread Eric V. Smith
Eric V. Smith added the comment: I agree with Mark. Also, if we're going to change the C implementation, the Python implementation should agree with it. -- ___ Python tracker

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-04 Thread Mark Dickinson
Mark Dickinson added the comment: I think the two main reasons that applied to not implementing the parsing part of PEP 515 for the Decimal type (speed, compliance with the IBM specification) don't apply to the formatting side. We do need to think about the implications of making local

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-04 Thread Mark Dickinson
Change by Mark Dickinson : -- nosy: +eric.smith, mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-04 Thread Nikita Sobolev
Nikita Sobolev added the comment: It is not hard to fix (https://github.com/python/cpython/blob/2c045bd5673d56c3fdde7536da9df1c7d6f270f0/Modules/_decimal/libmpdec/io.c#L857-L863): ```c /* thousands separator */ if (*cp == ',' || *cp == '_') { spec->dot = "."; if (*cp

[issue45708] PEP 515-style formatting with underscores does not seem to work for Decimal

2021-11-04 Thread Sander Bollen
New submission from Sander Bollen : Hello, It appears that Decimal does not support PEP-515 style formatting with underscores as thousands separators. ``` >>> from decimal import Decimal >>> f"{Decimal('5000'):,}" '5,000' >>> f"{Decimal('5000'):_}" Traceback (most recent call last): File