Message405895
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. |
|
Date |
User |
Action |
Args |
2021-11-07 09:27:32 | mark.dickinson | set | recipients:
+ mark.dickinson, tim.peters, rhettinger, eric.smith, christian.heimes, serhiy.storchaka, sobolevn, sndrtj |
2021-11-07 09:27:32 | mark.dickinson | set | messageid: <1636277252.8.0.708397671958.issue45708@roundup.psfhosted.org> |
2021-11-07 09:27:32 | mark.dickinson | link | issue45708 messages |
2021-11-07 09:27:32 | mark.dickinson | create | |
|