Skip to content

Commit 8ac090f

Browse files
committed
gh-150942: Speed up ElementTree attribute parsing
1 parent 32104a1 commit 8ac090f

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Speed up :mod:`xml.etree.ElementTree` parsing of element attributes by using
2+
reference-stealing dict insertion.

Modules/_elementtree.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3343,9 +3343,7 @@ expat_start_handler(void *op, const XML_Char *tag_in,
33433343
Py_DECREF(tag);
33443344
return;
33453345
}
3346-
ok = PyDict_SetItem(attrib, key, value);
3347-
Py_DECREF(value);
3348-
Py_DECREF(key);
3346+
ok = _PyDict_SetItem_Take2((PyDictObject *)attrib, key, value);
33493347
if (ok < 0) {
33503348
Py_DECREF(attrib);
33513349
Py_DECREF(tag);

0 commit comments

Comments
 (0)