pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/a28a3967ab9a189122f895d51d2551f7b3a273b0

gh-111666: Speed up `BaseExceptionGroup.{derive,split,subgroup}` (#11… · python/cpython@a28a396 · GitHub
Skip to content

Commit a28a396

Browse files
authored
gh-111666: Speed up BaseExceptionGroup.{derive,split,subgroup} (#111667)
1 parent 890ef1b commit a28a396

2 files changed

Lines changed: 9 additions & 20 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Speed up :meth:`BaseExceptionGroup.derive`,
2+
:meth:`BaseExceptionGroup.subgroup`, and :meth:`BaseExceptionGroup.split` by
3+
changing how they parse passed arguments.

Objects/exceptions.c

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -876,13 +876,9 @@ BaseExceptionGroup_str(PyBaseExceptionGroupObject *self)
876876
}
877877

878878
static PyObject *
879-
BaseExceptionGroup_derive(PyObject *self_, PyObject *args)
879+
BaseExceptionGroup_derive(PyObject *self_, PyObject *excs)
880880
{
881881
PyBaseExceptionGroupObject *self = _PyBaseExceptionGroupObject_cast(self_);
882-
PyObject *excs = NULL;
883-
if (!PyArg_ParseTuple(args, "O", &excs)) {
884-
return NULL;
885-
}
886882
PyObject *init_args = PyTuple_Pack(2, self->msg, excs);
887883
if (!init_args) {
888884
return NULL;
@@ -1176,13 +1172,8 @@ exceptiongroup_split_recursive(PyObject *exc,
11761172
}
11771173

11781174
static PyObject *
1179-
BaseExceptionGroup_split(PyObject *self, PyObject *args)
1175+
BaseExceptionGroup_split(PyObject *self, PyObject *matcher_value)
11801176
{
1181-
PyObject *matcher_value = NULL;
1182-
if (!PyArg_UnpackTuple(args, "split", 1, 1, &matcher_value)) {
1183-
return NULL;
1184-
}
1185-
11861177
_exceptiongroup_split_matcher_type matcher_type;
11871178
if (get_matcher_type(matcher_value, &matcher_type) < 0) {
11881179
return NULL;
@@ -1207,13 +1198,8 @@ BaseExceptionGroup_split(PyObject *self, PyObject *args)
12071198
}
12081199

12091200
static PyObject *
1210-
BaseExceptionGroup_subgroup(PyObject *self, PyObject *args)
1201+
BaseExceptionGroup_subgroup(PyObject *self, PyObject *matcher_value)
12111202
{
1212-
PyObject *matcher_value = NULL;
1213-
if (!PyArg_UnpackTuple(args, "subgroup", 1, 1, &matcher_value)) {
1214-
return NULL;
1215-
}
1216-
12171203
_exceptiongroup_split_matcher_type matcher_type;
12181204
if (get_matcher_type(matcher_value, &matcher_type) < 0) {
12191205
return NULL;
@@ -1488,9 +1474,9 @@ static PyMemberDef BaseExceptionGroup_members[] = {
14881474
static PyMethodDef BaseExceptionGroup_methods[] = {
14891475
{"__class_getitem__", (PyCFunction)Py_GenericAlias,
14901476
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
1491-
{"derive", (PyCFunction)BaseExceptionGroup_derive, METH_VARARGS},
1492-
{"split", (PyCFunction)BaseExceptionGroup_split, METH_VARARGS},
1493-
{"subgroup", (PyCFunction)BaseExceptionGroup_subgroup, METH_VARARGS},
1477+
{"derive", (PyCFunction)BaseExceptionGroup_derive, METH_O},
1478+
{"split", (PyCFunction)BaseExceptionGroup_split, METH_O},
1479+
{"subgroup", (PyCFunction)BaseExceptionGroup_subgroup, METH_O},
14941480
{NULL}
14951481
};
14961482

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy