This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients christian.heimes, eric.smith, mark.dickinson, rhettinger, serhiy.storchaka, sndrtj, sobolevn, tim.peters
Date 2021-11-07.09:27:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1636277252.8.0.708397671958.issue45708@roundup.psfhosted.org>
In-reply-to
Content
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 its way into core Python.
2. Bypass mpd_parse_fmt_str and do our own format string parsing in _decimal.c (e.g., by copying and adapting the code in mpdecimal).
3. Wrap mpd_parse_fmt_str and do our own pre- and post- processing in _decimal.c (pre-process to convert "_" to "," in the format string, then post-process the formatted string to convert "," back to "_").

Option 2 makes sense to me from the point of view of separation of concerns: libmpdec aims to implement Cowlishaw's specification, and formatting lies outside of that specification. The decimal specification is pretty much set in stone, but the formatting mini-language could change again in the future, and when that happens we should be able to update the CPython code accordingly. (This brings to mind Robert Martin's Single Responsibility Principle: "Gather together those things that change for the same reason, and separate those things that change for different reasons.") 

I've updated the PR (and turned it into a draft) to show what option 2 looks like. The duplication is a little ugly.
History
Date User Action Args
2021-11-07 09:27:32mark.dickinsonsetrecipients: + mark.dickinson, tim.peters, rhettinger, eric.smith, christian.heimes, serhiy.storchaka, sobolevn, sndrtj
2021-11-07 09:27:32mark.dickinsonsetmessageid: <1636277252.8.0.708397671958.issue45708@roundup.psfhosted.org>
2021-11-07 09:27:32mark.dickinsonlinkissue45708 messages
2021-11-07 09:27:32mark.dickinsoncreate