[issue44160] speed up searching for keywords by using a dictionary

2021-05-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: BTW, we use different approaches for builtin and Python functions. * For Python functions: iterate all keyword arguments and search in the list of keyword parameter names. * For builtin functions: iterate all keyword parameters and search in the list of

[issue44160] speed up searching for keywords by using a dictionary

2021-05-18 Thread Eric V. Smith
Eric V. Smith added the comment: Maybe the XXX comment in ceval.c should be removed? If we wouldn't change the code to use a dictionary, then that comment seems incorrect. -- nosy: +eric.smith ___ Python tracker

[issue44160] speed up searching for keywords by using a dictionary

2021-05-18 Thread Dennis Sweeney
Dennis Sweeney added the comment: Good catch -- with interning, the cutoff is more like 20-50, so it's probably not worth optimizing for. Before: 1 --> 1.67e-07 2 --> 1.77e-07 3 --> 1.90e-07 4 --> 2.05e-07 5 --> 2.14e-07 6 --> 2.35e-07 7 --> 2.51e-07 8 --> 2.67e-07 9 --> 2.76e-07 10 -->

[issue44160] speed up searching for keywords by using a dictionary

2021-05-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Please repeat benchmarking for interned names: kwargs = {sys.intern("a"*i): None for i in range(1, N+1)} and for more distinctive names: kwargs = {sys.intern(f"a{i}"): None for i in range(1, N+1)} I guess the difference will be lesser.

[issue44160] speed up searching for keywords by using a dictionary

2021-05-17 Thread Dennis Sweeney
Change by Dennis Sweeney : -- keywords: +patch pull_requests: +24817 stage: -> patch review pull_request: https://github.com/python/cpython/pull/26200 ___ Python tracker ___

[issue44160] speed up searching for keywords by using a dictionary

2021-05-17 Thread Dennis Sweeney
New submission from Dennis Sweeney : This patch ensures keyword-passing happens in linear time, fulfilling the 26-year-old TODO comment in ceval.c: XXX speed up searching for keywords by using a dictionary from time import perf_counter from itertools import repeat def bench(N): reps