Skip to content

do one big resize at dict creation#21881

Closed
Marco-Sulla wants to merge 8 commits into
python:masterfrom
Marco-Sulla:master
Closed

do one big resize at dict creation#21881
Marco-Sulla wants to merge 8 commits into
python:masterfrom
Marco-Sulla:master

Conversation

@Marco-Sulla

Copy link
Copy Markdown

Preliminary commit for some speedup to dict creation

@methane

methane commented Aug 15, 2020

Copy link
Copy Markdown
Member

Could you provide benchmark? I don't think this optimization is worth enough, because dict_new uses dummy key object instead of creating new small key object, and dict_merge does "one big resize".

@Marco-Sulla

Marco-Sulla commented Aug 15, 2020

Copy link
Copy Markdown
Author

Could you provide benchmark? I don't think this optimization is worth enough, because dict_new uses dummy key object instead of creating new small key object, and dict_merge does "one big resize".

As I wrote in the comment, there's no optimization for now. This is preliminary for other optimizations (briefly, since the resize is done in dict_new and not in dict_merge, we can create an optimized version of dict_merge that skips a lot of checks).

I'm doing this because it's really difficult to merge the code I wrote for frozendict, since I used a CPython code older of many months.

About keys object, we can simply change new_keys_object(PyDict_MINSIZE); to new_keys_object(arg_size + kwds_size);

@methane

methane commented Aug 16, 2020

Copy link
Copy Markdown
Member

Then I can not accept this PR.

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.

4 participants