| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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>
|
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. |
Sorry, something went wrong.
Both variants ultimately call PyModule_GetState, right? [with (1) caching its result into a field of self 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 to PyModule_GetState of (2). |
Sorry, something went wrong.
PyModule_GetState is called for module level functions, PyType_GetModuleState for class methods (via defining class), and PyType_GetModuleByDef plus PyModule_GetState for slots. The two former are inexpensive lookups, the latter is slightly slower. Caching state in self 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. |
Sorry, something went wrong.
|
I ran the pyperformance xml_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. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.