Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-92123: Move _elementtree heap types to module state#101187

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@erlend-aasland
Copy link
Contributor

@erlend-aaslanderlend-aasland commentedJan 20, 2023
edited
Loading

Erlend E. Aaslandand others added24 commitsJanuary 11, 2021 09:43
Pass state as an argument to Element_CheckExact()
Pass state as an argument to Element_Check()
Pass state as an argument to TreeBuilder_CheckExact()
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
@erlend-aasland
Copy link
ContributorAuthor

erlend-aasland commentedJan 21, 2023
edited
Loading

Thanks for the reviews, Kumar and Oleg!

For the path forward, there are two options: either pass state as a parameter, or store it in the type structs. I've created draft PRs for the two alternatives. Of course, a third path is a combination of both.

arhadthedev reacted with thumbs up emoji

@erlend-aaslanderlend-aasland merged commit13566a3 intopython:mainJan 21, 2023
@erlend-aaslanderlend-aasland deleted the etree/move-heap-types-to-state branchJanuary 21, 2023 11:01
@arhadthedev
Copy link
Member

For the path forward, there are three options: either pass state as a parameter, store it in the type structs.

Both variants ultimately callPyModule_GetState, right? [with(1) caching its result into a field ofself and(2) plainly calling it each time on demand]

If so, we need an informed decision by benchmarking some_elementtree method in both options. It should show whether direct structure access of(1) is faster than preheated call toPyModule_GetState of(2).

@erlend-aasland
Copy link
ContributorAuthor

erlend-aasland commentedJan 21, 2023
edited
Loading

Both variants ultimately callPyModule_GetState, right?

PyModule_GetState is called for module level functions,PyType_GetModuleState for class methods (via defining class), andPyType_GetModuleByDef plusPyModule_GetState for slots. The two former are inexpensive lookups, the latter is slightly slower. Caching state inself results in more memory usage (might only be important for the Element type). I'd be surprised if it is possible to measure the performance impact of this, but sure let's do some benchmarking.

@erlend-aasland
Copy link
ContributorAuthor

I ran the pyperformancexml_etree benchmark towards all three alternatives (1: pass state around as a parameter, 2: store state in the heap type contexts, 3: store state in TreeBuilder and XMLParser contexts, but pass it around for Element and its iter). I could not measure a significant difference any of the alternatives.

@kumaraditya303
Copy link
Contributor

It won't matter as expected as most of the time as long as there isn't much stack spilling the performance should be identical.

erlend-aasland reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@arhadthedevarhadthedevarhadthedev left review comments

@kumaraditya303kumaraditya303kumaraditya303 approved these changes

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@erlend-aasland@arhadthedev@kumaraditya303@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp