Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-41835: Speedup to dict vectorcall with keyword arguments. #22346

Closed
wants to merge 14 commits into from
Closed

bpo-41835: Speedup to dict vectorcall with keyword arguments. #22346

wants to merge 14 commits into from

Conversation

Marco-Sulla
Copy link
Contributor

@Marco-Sulla Marco-Sulla commented Sep 21, 2020

I added a specialized version of insertdict, insertdict_init, that assumes any needed resize to the dict is done before the inserting.

Also done some minor and cosmetic change.

https://bugs.python.org/issue41835

Copy link
Contributor

@eamanu eamanu left a comment

Please, this PR definitely need a bpo for discussion, and NEWS.

@sweeneyde
Copy link
Member

sweeneyde commented Sep 23, 2020

Do you have a microbenchmark for what specific thing is being optimized? I'd recommend using pyperf and posting the results to an issue at bugs.python.org.

From the Dev Guide:

  • Do not do cosmetic changes to unrelated code in the same commit as some feature/bugfix.

It seems like most of the diff is filled with these. I think the general guideline is to keep the diff as small as possible. I would think that the PR should limit changing cosmetics (const qualifiers, delayed declarations, whitespace, braces, changing ifs to asserts) to the couple of functions that the PR is to focus on. Finally, the change to .gitignore looks unrelated to the suggestion.

Is there anything positive accomplished by moving behavior from public functions like PyDict_SetItem and PyDict_GetItemWithError into new identical static-scope functions? If anything, I think the existing usage of the public functions is good because it gives examples of how the API is to be used outside of this file.

.gitignore Outdated Show resolved Hide resolved
@Marco-Sulla
Copy link
Contributor Author

Marco-Sulla commented Sep 23, 2020

@sweeneyde: I removed all the minor and cosmetic changes.

About PyDict_SetItem and the other one, I followed the example of setobject.c, where all the public functions calls the static internal functions. IMHO it's more clear. Furthermore, should it save you some nanoseconds (static objects are allocated in the stack)?

@methane
Copy link
Member

methane commented Oct 22, 2020

@Marco-Sulla Please create bpo issue and post benchmark&result to it.

@Marco-Sulla
Copy link
Contributor Author

Marco-Sulla commented Oct 22, 2020

@methane I already created it: https://bugs.python.org/issue41835

@methane methane changed the title Speedup to dict vectorcall with keyword arguments. bpo-41835: Speedup to dict vectorcall with keyword arguments. Oct 22, 2020
Copy link
Member

@methane methane left a comment

Remove trailing whitespaces.

I am not sure this is the best performance/complexity way. So I am trying some other ideas. Please wait.

Objects/dictobject.c Outdated Show resolved Hide resolved
@Marco-Sulla Marco-Sulla requested a review from markshannon as a code owner Oct 30, 2020
@methane methane closed this Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants