classification
Title: Simplify the interpreter's (type, val, tb) exception representation
Type: performance Stage: patch review
Components: Interpreter Core Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Mark.Shannon, brandtbucher, gvanrossum, iritkatriel, terry.reedy
Priority: normal Keywords: patch

Created on 2021-11-04 11:29 by iritkatriel, last changed 2021-11-18 19:25 by iritkatriel.

Pull Requests
URL Status Linked Edit
PR 29404 merged iritkatriel, 2021-11-04 13:24
PR 29495 merged iritkatriel, 2021-11-09 17:32
PR 29518 merged iritkatriel, 2021-11-10 19:17
PR 29528 merged brandtbucher, 2021-11-11 23:41
PR 29627 open iritkatriel, 2021-11-18 19:25
Messages (7)
msg405681 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-11-04 11:29
Exceptions are represented in the interpreter as (type, val, tb) triplets which most of the time contain redundant information (the type is the type of val and the tb is also on the exception). This complicates the code and is inefficient as opcodes that manage exceptions push and pop 3 items for each exception. 

We will change the internal representation to be (1) just the exception value if it is normalised and (2) a tuple of the 3 values for the uncommon case where they are all needed.

See also https://github.com/faster-cpython/ideas/issues/106.
msg405839 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-11-06 01:34
Would there be any change at the Python level?
msg405849 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-11-06 07:53
Initially not, neither in python nor in the c api.

It would be nice to replace PyErr_Fetch/Restore by a version that takes just an exception but that’s a long deprecation.
msg406114 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-11-10 16:57
New changeset 05fbd60147456d77a7aecf29dddd86c5bde5872f by Irit Katriel in branch 'main':
bpo-45711: Use _PyErr_ClearExcState instead of setting only exc_value to NULL (GH-29404)
https://github.com/python/cpython/commit/05fbd60147456d77a7aecf29dddd86c5bde5872f
msg406120 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-11-10 18:08
New changeset 4cdeee5978ee3f8ea7fe95172ae04d866cd88177 by Irit Katriel in branch 'main':
bpo-45711: remove unnecessary DUP_TOP and POP in exception handling (GH-29495)
https://github.com/python/cpython/commit/4cdeee5978ee3f8ea7fe95172ae04d866cd88177
msg406209 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-11-12 13:21
New changeset 8f1b71de731dda668aede7c9b34d0ad7afb8f6a8 by Brandt Bucher in branch 'main':
bpo-45711: Re-bump the magic number and update doc (GH-29528)
https://github.com/python/cpython/commit/8f1b71de731dda668aede7c9b34d0ad7afb8f6a8
msg406238 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-11-12 21:37
New changeset de3db1448b1b983eeb9f4498d07e3d2f1fb6d29d by Irit Katriel in branch 'main':
bpo-45711: assert that the type of exc_info is redundant (GH-29518)
https://github.com/python/cpython/commit/de3db1448b1b983eeb9f4498d07e3d2f1fb6d29d
History
Date User Action Args
2021-11-18 19:25:08iritkatrielsetpull_requests: + pull_request27859
2021-11-12 21:37:36iritkatrielsetmessages: + msg406238
2021-11-12 13:21:53iritkatrielsetmessages: + msg406209
2021-11-11 23:41:36brandtbuchersetnosy: + brandtbucher
pull_requests: + pull_request27778
2021-11-10 19:17:44iritkatrielsetpull_requests: + pull_request27770
2021-11-10 18:08:41Mark.Shannonsetmessages: + msg406120
2021-11-10 16:57:23iritkatrielsetmessages: + msg406114
2021-11-09 17:32:00iritkatrielsetpull_requests: + pull_request27745
2021-11-06 07:53:27iritkatrielsetmessages: + msg405849
2021-11-06 01:34:06terry.reedysettype: performance

messages: + msg405839
nosy: + terry.reedy
2021-11-04 13:24:54iritkatrielsetkeywords: + patch
stage: patch review
pull_requests: + pull_request27660
2021-11-04 11:29:47iritkatrielcreate