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.
Created on 2022年02月25日 00:07 by vstinner, last changed 2022年04月11日 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 31558 | merged | vstinner, 2022年02月25日 01:06 | |
| PR 31578 | merged | vstinner, 2022年02月25日 14:26 | |
| PR 31581 | merged | vstinner, 2022年02月25日 14:51 | |
| PR 31585 | merged | vstinner, 2022年02月25日 15:18 | |
| PR 31592 | closed | vstinner, 2022年02月26日 00:15 | |
| PR 31601 | merged | vstinner, 2022年02月26日 23:08 | |
| Messages (17) | |||
|---|---|---|---|
| msg413943 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2022年02月25日 00:07 | |
It has been decided to require IEEE 754 to build Python 3.11: https://mail.python.org/archives/list/python-dev@python.org/thread/J5FSP6J4EITPY5C2UJI7HSL2GQCTCUWN/ At Python startup, _PyFloat_InitState() checks the IEEE 754 format at runtime. It can be changed using float.__get_format__() and float.__set_format__() methods. These methods docstrings say that they only exist to test Python itself: "You probably don't want to use this function. It exists mainly to be used in Python's test suite." These methods are private and not documented. I propose to remove them. Once they will be removed, it will become possible to move the detection of the IEEE 754 format in the build step (./configure script) rather than doing the detection at runtime (slower). It would remove an "if" in _PyFloat_Pack4() and _PyFloat_Pack8(), and allow to specialize these functions for the detected format at build time. These functions are used by serialization formats: marshal, pickle and struct. |
|||
| msg413946 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2022年02月25日 00:40 | |
I would not miss these methods. Unless Mark says they are needed, +1 for removal. |
|||
| msg413947 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2022年02月25日 00:48 | |
See also bpo-46656: "Remove the Py_NO_NAN macro: require NAN to build Python 3.11". |
|||
| msg413948 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2022年02月25日 00:54 | |
Oh wait, I'm now confused by the method names. In Python 3.10, the correct names at: * float.__getformat__() <= 4 underscores * float.__set_format__() <= 5 underscores It's even more confusing because the "set format" is only used in one place: test_float, and test_float uses... __setformat__() (4 underscores). A typo a was introduced in Python 3.7 by: commit b5c51d3dd95bbfde533655fb86ac0f96f771ba7b Author: Serhiy Storchaka <storchaka@gmail.com> Date: Sat Mar 11 09:21:05 2017 +0200 bpo-20185: Convert float object implementation to Argument Clinic. (#543) Based on patch by Vajrasky Kok. Since Python 3.7, the 4 "set format" tests are simply skipped! $ ./python -m test -v test_float (...) test_getformat (test.test_float.FormatFunctionsTestCase) ... skipped 'requires __setformat__' test_setformat (test.test_float.FormatFunctionsTestCase) ... skipped 'requires __setformat__' (...) test_double_specials_dont_unpack (test.test_float.UnknownFormatTestCase) ... skipped 'requires __setformat__' test_float_specials_dont_unpack (test.test_float.UnknownFormatTestCase) ... skipped 'requires __setformat__' (...) Moreover, unittest.mock supports mocking __setformat__() (4 underscores). |
|||
| msg413949 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2022年02月25日 01:06 | |
I wrote GH-31558 to fix the typo in the method name. |
|||
| msg413950 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2022年02月25日 01:10 | |
We can keep the float.__getformat__() method, it doesn't harm. I change the issue title to only propose to remove the float.__setformat__() method. |
|||
| msg413953 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2022年02月25日 02:05 | |
New changeset 7d03c8be5af2f1559dbc35b775b3116dfd63cfb6 by Victor Stinner in branch 'main': bpo-46852: Rename float.__set_format__() to float.__setformat__() (GH-31558) https://github.com/python/cpython/commit/7d03c8be5af2f1559dbc35b775b3116dfd63cfb6 |
|||
| msg413997 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2022年02月25日 14:47 | |
New changeset 0848da19ce8ea037ab1cfc569778e94bf8e3b24a by Victor Stinner in branch '3.10': bpo-46852: Rename float.__set_format__() to float.__setformat__() (GH-31558) (GH-31578) https://github.com/python/cpython/commit/0848da19ce8ea037ab1cfc569778e94bf8e3b24a |
|||
| msg414005 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2022年02月25日 15:13 | |
New changeset a549cd1fc55888e2e287714b25e2cb2251913909 by Victor Stinner in branch '3.9': bpo-46852: Rename float.__set_format__() to float.__setformat__() (GH-31558) (GH-31581) https://github.com/python/cpython/commit/a549cd1fc55888e2e287714b25e2cb2251913909 |
|||
| msg414011 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2022年02月25日 15:58 | |
I'd be happy to see `float.__setformat__` go, if it's not still needed for Python's test suite (which was its entire raison d'être). If no-one noticed the accidental misnaming, then it's pretty clear no-one's been using it. I'd like to bet that there are at least a few people out there using float.__getformat__, despite that its docstring says "You probably don't want to use this function". Maybe we could consider moving the information contained in __getformat__ to somewhere more accessible (e.g., a new field in sys.float_info)? |
|||
| msg414018 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2022年02月25日 16:49 | |
Mark Dickinson: > I'd be happy to see `float.__setformat__` go, if it's not still needed for Python's test suite (which was its entire raison d'être). If no-one noticed the accidental misnaming, then it's pretty clear no-one's been using it. Nobody noticed the since Python 3.7 (released in June 2018). Well, even test_float didn't use it :-D (I just fixed the typo yesterday.) So I expect that no one uses it. > I'd like to bet that there are at least a few people out there using float.__getformat__, despite that its docstring says "You probably don't want to use this function". Yeah, I changed my mind and I prefer to leave it unchanged for now. It doesn't prevent me to optimize _PyFloat_Pack8(). |
|||
| msg414050 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2022年02月25日 23:53 | |
New changeset 5ab745fc51e159ead28b523414e52f0bcc1ef353 by Victor Stinner in branch 'main': bpo-46852: Remove the float.__set_format__() method (GH-31585) https://github.com/python/cpython/commit/5ab745fc51e159ead28b523414e52f0bcc1ef353 |
|||
| msg414131 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2022年02月27日 00:12 | |
New changeset 5a1c637ec6264790d3cfeef46815c62c32b510f3 by Victor Stinner in branch 'main': bpo-46852: Restore test_getformat() test (GH-31601) https://github.com/python/cpython/commit/5a1c637ec6264790d3cfeef46815c62c32b510f3 |
|||
| msg414150 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2022年02月27日 13:22 | |
Thanks, Victor. I think this can be closed now. |
|||
| msg414152 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2022年02月27日 13:49 | |
I reopen the issue for the second part of my plan: "Once they will be removed, it will become possible to move the detection of the IEEE 754 format in the build step (./configure script) rather than doing the detection at runtime (slower). It would remove an "if" in _PyFloat_Pack4() and _PyFloat_Pack8(), and allow to specialize these functions for the detected format at build time. These functions are used by serialization formats: marshal, pickle and struct." |
|||
| msg414158 - (view) | Author: Mark Dickinson (mark.dickinson) * (Python committer) | Date: 2022年02月27日 15:30 | |
> I reopen the issue for the second part of my plan Hmm. That sounds like it should be a separate issue, or at the least, this issue should be retitled. It's helpful to keep issue titles accurate. |
|||
| msg414493 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2022年03月03日 23:39 | |
I created a follow-up issue: bpo-46917 "Require IEEE 754 floating point to build Python 3.11". I close this one: float.__set_format__() has been removed. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:59:56 | admin | set | github: 91008 |
| 2022年03月03日 23:39:31 | vstinner | set | status: open -> closed resolution: fixed messages: + msg414493 title: Remove the float.__setformat__() method -> Remove the float.__set_format__() method |
| 2022年02月27日 15:30:31 | mark.dickinson | set | messages: + msg414158 |
| 2022年02月27日 13:49:39 | vstinner | set | status: closed -> open resolution: fixed -> (no value) messages: + msg414152 |
| 2022年02月27日 13:22:15 | mark.dickinson | set | status: open -> closed resolution: fixed messages: + msg414150 stage: patch review -> resolved |
| 2022年02月27日 00:12:37 | vstinner | set | messages: + msg414131 |
| 2022年02月26日 23:08:33 | vstinner | set | pull_requests: + pull_request29724 |
| 2022年02月26日 00:15:14 | vstinner | set | pull_requests: + pull_request29715 |
| 2022年02月25日 23:53:38 | vstinner | set | messages: + msg414050 |
| 2022年02月25日 16:49:11 | vstinner | set | messages: + msg414018 |
| 2022年02月25日 15:58:46 | mark.dickinson | set | messages: + msg414011 |
| 2022年02月25日 15:18:24 | vstinner | set | pull_requests: + pull_request29708 |
| 2022年02月25日 15:13:53 | vstinner | set | messages: + msg414005 |
| 2022年02月25日 14:51:09 | vstinner | set | pull_requests: + pull_request29704 |
| 2022年02月25日 14:47:14 | vstinner | set | messages: + msg413997 |
| 2022年02月25日 14:26:29 | vstinner | set | pull_requests: + pull_request29700 |
| 2022年02月25日 02:05:45 | vstinner | set | messages: + msg413953 |
| 2022年02月25日 01:10:59 | vstinner | set | messages:
+ msg413950 title: Remove float.__get_format__() and float.__set_format__() -> Remove the float.__setformat__() method |
| 2022年02月25日 01:06:52 | vstinner | set | messages: + msg413949 |
| 2022年02月25日 01:06:10 | vstinner | set | keywords:
+ patch stage: patch review pull_requests: + pull_request29680 |
| 2022年02月25日 00:54:40 | vstinner | set | messages: + msg413948 |
| 2022年02月25日 00:48:34 | vstinner | set | messages: + msg413947 |
| 2022年02月25日 00:40:46 | rhettinger | set | nosy:
+ rhettinger, mark.dickinson, tim.peters messages: + msg413946 |
| 2022年02月25日 00:07:57 | vstinner | create | |