|
Meta tags:
description=Add @vectorcall as a decorator to Argument Clinic (AC) which emits a Vectorcall Protocol argument parsing C function named type _vectorcall. This is only supported for __new__ and __init__ currently to simplify implementation.
The generated code has similar or better performance to existing hand-written cases for list, float, str, tuple, enumerate, reversed, and int. Using the decorator on bytearray, which has no handwritten case, construction got 1.09x faster. For more benchmark details see #87613 (comment).
The @vectorcall decorator has two options:
zero_arg= C_FUNC : Some types, like int, can be called with zero arguments and return an immortal object in that case. Adding a shortcut is needed to match existing hand-written performance; provides an over 10% performance change for those cases. -- removed in refactoring, delegated to the new/init implementation.
exact_only: If the type is not an exact match delegate to the existing non-vectorcall implementation. Needed for str to get matching performance while ensuring correct behavior.
Implementation details:
Adds support for the new decorator with arguments in the AC DSL Parser
Move keyword argument parsing generation from inline to a helper function so both vectorcall, vc_, and existing can share code generation.
Adds an emit helper to simplify code a bit from existing AC cases
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
Issue: gh-87613;
Headings (most frequently used words):
uh, oh, navigation, gh, 87613, argument, clinic, vectorcall, decorator, 145381, footer, diff, view, menu, repository, there, are, no, files, selected, for, viewing, filter, by, extension,
Text of the page (most frequently used words):
self (68), 2026 (50), cmaloney (47), ac_tester (38), #vectorcall (34), def (32), file (25), and (23), may (21), block (20), foo (18), this (17), the (17), clinic (17), github (16), for (16), err (15), assertisinstance (14), error (13), with (13), that (12), line (12), class (12), aug (12), applied (11), reload (11), __init__ (11), tools (11), test (11), args (11), code (10), all (10), loading (10), vcnewbase (10), module (10), suggestions (9), while (9), argument (9), show (9), hidden (9), characters (9), unicode (9), typeerror (9), cls (9), vcinit (9), vckwonly (9), fix (9), from (8), add (8), there (8), func (8), diff (8), expand (8), vcnew (8), _testclinic (8), expect_failure (8), lineno (8), fooobject (8), you (7), not (7), suggestion (7), cannot (7), please (7), merge (7), only (7), changes (7), was (7), __new__ (7), open (7), 87613 (7), assertraises (7), kwargs (7), sep (7), remove (7), main (7), into (7), ac_add_vectorcall (7), sign (7), can (6), comments (6), page (6), object (6), number (6), bidirectional (6), review (6), more (6), support (6), libclinic (6), branch (6), security (5), decorator (5), learn (5), about (5), view (5), issue (5), tuple (5), keyword (5), lib (5), slot (5), positional (5), through_new (5), foo_type (5), cpython (5), objects (5), modules (5), apply (5), nbsp (5), upstream (5), commits (5), your (5), pull (4), change (4), retry (4), parsing (4), what (4), news (4), next (4), rst (4), down (4), range (4), function (4), return (4), tp_new (4), match (4), helper (4), null (4), sub (4), build (4), files (4), globals (4), tsv (4), tupleobject (4), enumobject (4), remote (4), tracking (4), simplify (4), mar (4), copilot (4), community (3), navigation (3), check (3), request (3), has (3), resolved (3), batch (3), commit (3), wrong (3), original (3), contains (3), text (3), interpreted (3), compiled (3), differently (3), than (3), appears (3), below (3), editor (3), reveals (3), desktop (3), delete (3), edit (3), misc (3), demos (3), nwzu6u (3), additions (3), deletions (3), assertequal (3), test_tuple (3), unittest (3), direct (3), arguments (3), through (3), str (3), messages (3), obj (3), test_clinic (3), 207 (3), parse_args (3), analyzer (3), hide (3), whitespace (3), filter (3), out (3), refactor (3), move (3), 145381 (3), merged (3), python (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), contact (2), status (2), privacy (2), terms (2), footer (2), now (2), back (2), marked (2), single (2), one (2), viewing (2), were (2), toggle (2), oops (2), something (2), went (2), testcase (2), invalid_calls (2), entry_points (2), too (2), through_init (2), enumerate (2), non (2), partial (2), tp_init (2), pytype_genericnew (2), none (2), exc (2), calls (2), tp_vectorcall (2), should (2), kwnames (2), type (2), types (2), kwds (2), conversation (2), encukou (2), comment (2), does (2), groups (2), encoding (2), classmethod (2), parse_arg (2), requires (2), implementation (2), asserttrue (2), function_index (2), parse_function (2), signatures_in_block (2), used (2), methods (2), 644 (2), are (2), selected (2), dsl_parser (2), clanguage (2), app (2), _parser (2), _testclinic_kwds (2), _testclinic_depr (2), split (2), unified (2), failed (2), load (2), jump (2), extension (2), case (2), batched (2), update (2), exact_only (2), jul (2), some (2), jun (2), select (2), tree (2), insights (2), projects (2), actions (2), repository (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, later, queued, multi, pending, reviews, been, outdated, must, existing, order, create, valid, applying, deleted, lines, supported, per, subset, closed, invalid, because, made, annotations, notes, generate, ref, sequence, assertraisesregex, test_keyword_args, test_too_many_args, test_constructors, setup, limitedcapioutputtests, subtest, unknown, many, few, wrapper, instance, subclassable, reach, except, try, subtype, will, hit, errors, explicit, well, test_parse_errors_match_slot, test_vc_kwonly_missing_required, test_vc_kwonly_b_as_positional, every, call, goes, fast, path, test_vc_kwonly, debug, aborts, here, ever, stops, holding, generated, asserts, inherited, subclass, constructed, test_vc_new_base_subclass, test_vc_new_base_missing_required, test_vc_new_base, test_vc_init_rejects_a_as_keyword, test_vc_init_missing_required, test_vc_init, test_vc_new_rejects_extra_args, test_vc_new, runtime, tests, exemplar, vectorcallfunctionaltest, skipif, missing, kwds_with_pos_only_and_stararg, 5020, 5128, 105, test_kwds_with_pos_only_and_stararg, parse, test_unused_param, thread, optional, test_vectorcall_with_option_groups, utf, parameter, converters, test_vectorcall_unsupported_converter, test_vectorcall_without_type_object, bogus, true, at_vectorcall, takes, but, given, test_vectorcall_takes_no_arguments, test_vectorcall_on_new, iterable, test_vectorcall_on_init, test_vectorcall_on_module_function, some_method, test_vectorcall_on_regular_method, called, twice, test_duplicate_vectorcall, 2887, 2889, 112, test_duplicate_coexist, impl_definition, methoddef_ifndef, cpp_endif, vectorcall_definition, parser_definition, parser_helper, parser_prototype, impl_prototype, methoddef_define, test_directive_output_invalid_command, conversations, clear, filters, viewed, switch, instead, tp_alloc, enables, bytearray, 0c39c87, 31cffb5, _parse_args, _helper, 48a70ab, building, helper_call, complexity, bdb5591, 64b3211, afee565, disable, combining, option, 52db6f7, 5488010, _check_positional, callsites, 88d5928, condition, simplified, varpos, needs, c2b8174, combine, 6d8f207, 9135933, use, 67e9a37, between, 70a6a68, assert, windows, builds, 3bc0054, recent, e4b4f0b, suggetions, eendebakpt, drop, 011e5c3, 5e8e2a3, grammar, 9357436, mypy, 63c1dc5, codegeneration, bc744b2, wording, d897215, exercise, critical, section, generation, testclinic, a19e9a8, duplicate, prototypes, 2a7c068, unnecessary, b1cd7b6, where, allowed, increase, cover, 61ada45, kwarg, when, emitting, two, pars, 7f56bb0, removed, 7e089b0, 1dcc72b, e4d18aa, failures, dedup, 420d705, dataclass, 446bce5, lint, e9aff2f, zero_arg, 379fd85, exclude, b96c326, limit, bit, 71b0d8e, ignore, very, large, b5d2e40, 61746eb, cases, 04a148c, 115a524, sample, testing, 3698a32, a243517, reversed, enum, 15f74e8, blurb, a9d0d6f, feb, cliic, 947e149, hold, shift, click, changed, checks, already, clicking, agree, our, occasionally, send, related, emails, statement, service, free, its, maintainers, have, question, project, new, items, requests, issues, message, dismiss, alert, switched, accounts, 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,
|