|
Meta tags:
description=Add working code generation for @vectorcall with **kwargs. The first commit adds support to libclinic converters to get keyword args from stack form rather than a dict. When there are no keyword arguments avoid creating a dictionary.
Exercise that code generation with xml.etree.ElementTree.Element. This adds a small behavior change in that non-string keyword arguments will raise TypeError rather than succeeding. Such keys can still be passed in using attrib. @text_signature keeps the documented (tag, /, attrib= , **extra): attrib can still be passed by keyword, which the impl pops from extra.
Merging the keywords into the attributes now copies them with PyDict_Copy() instead of PyDict_New() plus PyDict_Update(), and pops attrib with _Py_ID(attrib) rather than creating a string per call; SubElement shares that helper.
pyperf microbenchmark (PGO+LTO, run serially):
Benchmark
base
Element
E( a , x= 1 )
116 ns
76.3 ns: 1.52x faster
E( a )
42.6 ns
28.2 ns: 1.51x faster
E( a , attrib=d)
122 ns
82.8 ns: 1.47x faster
E( a , d)
73.8 ns
53.6 ns: 1.38x faster
SE(E( p ), a , x= 1 )
161 ns
120 ns: 1.35x faster
E( a , d, y= 2 )
102 ns
80.3 ns: 1.27x faster
S( a )
49.4 ns
39.8 ns: 1.24x faster
Benchmark code:
import pyperf
runner = pyperf.Runner()
setup = ( from _elementtree import Element as E, SubElement as SE\n
d = x : 1 \n
class S(E): pass )
for stmt in [ E( a ) , E( a , d) , E( a , x= 1 ) , E( a , d, y= 2 ) ,
E( a , attrib=d) , S( a ) , SE(E( p ), a , x= 1 ) ]:
runner.timeit(stmt, stmt, setup)
Issue: gh-87613;
Headings (most frequently used words):
uh, oh, for, navigation, gh, 87613, support, kwargs, in, ac, vc, and, use, xml, etree, elementtree, element, 161597, footer, diff, view, menu, repository, there, are, no, files, selected, viewing, filter, by, extension,
Text of the page (most frequently used words):
file (61), attrib (47), line (30), self (28), this (24), the (23), #element (23), expand (21), show (21), hidden (21), characters (21), unicode (21), github (20), diff (20), and (20), that (19), open (19), tag (19), clinic (18), return (18), pyobject (18), number (16), kwds (16), null (15), include (15), all (14), for (14), bidirectional (14), text (14), comments (13), reload (13), def (13), learn (13), about (13), view (13), change (12), loading (12), more (12), files (12), you (11), applied (11), while (11), code (11), changes (11), desktop (11), delete (11), edit (11), extra (11), there (10), deletions (10), 87613 (10), please (9), str (9), internal (9), 2026 (8), was (8), error (8), page (8), retry (8), what (8), review (8), kwargs (8), are (8), generated (8), _elementtree (8), support (8), not (7), suggestion (7), cannot (7), suggestions (7), down (7), original (7), contains (7), may (7), interpreted (7), compiled (7), differently (7), than (7), appears (7), below (7), editor (7), reveals (7), class (7), its (7), xml (7), struct_for_id (7), cmaloney (7), sign (7), check (6), oops (6), something (6), went (6), wrong (6), tools (6), libclinic (6), args (6), additions (6), load (6), py_newref (6), self_elem (6), security (5), addition (5), modules (5), static (5), tail (5), get_attrib_from_keywords (5), etree (5), elementtree (5), issue (5), lib (5), test (5), commits (5), your (5), can (4), pull (4), param_name (4), dict (4), parse_var_keyword (4), some (4), rendered (4), default (4), how (4), customized (4), appear (4), element_init (4), attributes (4), length (4), _set_joined_ptr (4), py_none (4), py_decref (4), pydict_update (4), argument (4), input (4), python (4), with (4), next (4), rst (4), nbsp (4), use (4), copilot (4), community (3), navigation (3), request (3), from (3), must (3), add (3), batch (3), commit (3), closed (3), start (3), end (3), none (3), parameters (3), dsl_parser (3), stackargs (3), parser_name (3), keywords (3), empty (3), bool (3), should (3), converters (3), name (3), attribute (3), implementation (3), already (3), elementobject (3), else (3), _pydict_copyasdict (3), vectorcall (3), misc (3), news (3), library (3), 7lkjhs (3), foo (3), test_xml_etree (3), function (3), test_clinic (3), pycore_unicodeobject_generated (3), pycore_runtime_init_generated (3), pycore_global_strings (3), pycore_global_objects_fini_generated (3), hide (3), whitespace (3), filter (3), 161597 (3), account (3), quality (3), another (3), tab (3), window (3), refresh (3), session (3), developers (3), changelog (3), customer (3), enterprise (3), grade (3), features (3), build (3), contact (2), status (2), privacy (2), terms (2), footer (2), now (2), merge (2), single (2), one (2), viewing (2), toggle (2), c_name (2), match (2), 996 (2), py_xnewref (2), kwnames (2), py_xdecref (2), 1448 (2), varkeywordcconverter (2), raise (2), 1437 (2), 104 (2), py_tp_init (2), element_getsetlist (2), pytype_slot (2), element_slots (2), py_tp_doc (2), void (2), element_doc (2), child (2), example (2), form (2), given (2), keyword (2), arguments (2), containing (2), additional (2), optional (2), dictionary (2), want (2), truly (2), both (2), subelements (2), means (2), reference (2), interface (2), py_xsetref (2), create_extra (2), have (2), output (2), object (2), _py_id (2), keys (2), typeerror (2), 3022 (2), module (2), assertequal (2), 1847 (2), 327 (2), selected (2), parse_args (2), apply (2), split (2), unified (2), failed (2), jump (2), extension (2), oct (2), nov (2), select (2), tree (2), insights (2), projects (2), actions (2), repository (2), cpython (2), signed (2), universe (2), training (2), integrations (2), stories (2), center (2), documentation (2), business (2), fixes (2), products (2), secret (2), perform, action, time, share, personal, information, manage, cookies, docs, inc, right, back, later, queued, multi, pending, reviews, has, been, marked, resolved, outdated, existing, order, create, valid, applying, deleted, lines, supported, only, per, subset, invalid, because, were, made, annotations, notes, handle, too, parse_parameter, deletion, goto, exit, _pystack_asdict, nargs, when, call, allocates, cleanup, var_keyword_dict_converter, notimplementederror, never, called, assertionerror, limited_capi, displayname, argname, parse_arg, cconverter, 102, py_sq_length, element_length, py_tp_new, element_new, py_tp_alloc, pytype_genericalloc, py_tp_vectorcall, _elementtree_element_vectorcall, _elementtree_element___init__, py_tp_getset, py_tp_members, element_members, py_tp_methods, element_methods, 4480, 4482, py_tp_getattro, pyobject_genericgetattr, py_tp_repr, element_repr, py_tp_dealloc, element_dealloc, _elementtree_element___init____doc__, pydoc_strvar, 4451, 4472, pygetsetdef, replace, objects, pointed, 460, 481, is_empty_dict, 434, 457, frozendict, pyerr_format, pyexc_typeerror, pyanydict_check, pyarg_parsetuple, d10be095275d5d1a, a66a3eacbc30aa64, _elementtree_element___init___impl, int, c_default, __init__, text_signature, da39a3ee5e6b4b0d, 6c83ea832d2b0ef1, 413, 414, xmlparser, xmlparserobject, clinic_state, xmlparser_type, pydict_copy, pydict_new, py_setref, 393, 394, pydict_pop, pydict_popstring, 377, 378, pycore_weakref, ft_clear_weakrefs, pycore_tuple, _pytuple_frompair, pycore_runtime, pycore_pyhash, _py_hashsecret, pycore_dict, pycore_ceval, _py_enterrecursivecall, did, pass, such, instead, raises, exc, calling, non, string, zix, wyp, test___init__, qname, key, value, assertraisesregex, strings, test_extra_keys_must_be_strings, basicelementtest, elementtestcase, unittest, testcase, block, test_base_invalid_syntax, converter, kwargs_as_kwds, bar, parse_function, test_var_keyword_c_name, os_stat_fn, c_basename, test_c_name, backtick, autocommit, attr, athrow, ast, struct, _py_global_strings, conversations, clear, filters, viewed, types, allow, 285bfdd, copy, explicitly, e49ac09, 0f32147, 0461451, hold, shift, click, range, changed, checks, conversation, 100, 220, wants, into, clinic_vc_kwargs_pr, main, clicking, agree, our, occasionally, send, related, emails, statement, service, free, maintainers, question, project, new, items, requests, issues, message, dismiss, alert, switched, accounts, out, appearance, settings, search, pricing, event, talks, workshops, partners, company, forum, events, webinars, blog, resource, connect, resources, premium, advanced, ons, trust, why, evaluate, see, industries, government, manufacturing, financial, services, healthcare, industry, nonprofits, startups, team, enterprises, stage, businesses, source, latest, improvements, across, place, developer, articles, sponsors, trending, repos, explore, customize, certifications, scanning, leak, prevention, protection, vulnerability, detection, remediation, secure, cloud, development, environments, codespaces, analysis, enforcement, automation, ship, coding, agent, tasks, automated, work, hosting, collaboration, platform, menu, skip, content,
|