GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||
GeezerVison is showing github.com — Improve performance of name normalization by jaraco · Pull Request #533 · python/importlib_metadata Conversation
Member
Backport of changes from python/cpython#143658
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions…ance of `importlib.metadata.Prepared.normalized` (#143660) Co-authored-by: Henry Schreiner <[email protected]> Co-authored-by: Bénédikt Tran <[email protected]> Co-authored-by: Bartosz Sławecki <[email protected]> …ce of `importlib.metadata.Prepared.normalized` (#144083) Co-authored-by: Henry Schreiner <[email protected]>
Member
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
There was an error while loading. Please reload this page.
|
The latest benchmark shows a 74% reduction in execution time. I get different numbers when I run timeit manually (~230ns vs ~510ns, 55% reduction). Was it worth it to save a few hundred nanoseconds? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
In many cases, the speedup won't make any noticeable effect. The change is similar to an improvement from Let's also ask if @henryiii is aware of any use cases. Personally, I would make this change, I don't think it makes the code harder to read or maintain. But it's fine if you'd prefer to reject this and/or revert in CPython. btw I'd already opened #529 against This is the better PR -- same prod code change, but parametrised tests and a performance benchmark added. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Thanks for that PR; I'd just not gotten to it as my attention/bandwidth are limited. There's some documentation in https://github.com/python/importlib_metadata/wiki/Development-Methodology. And the contribution to main was the correct thing at the time. But because I'm now getting this change in place (along with some others) and there's a 9.0 release that I'd like to exclude for the time being, that's why I'm targeting 8.x. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…termediate implementations. Reference the rationale.
I would argue it is less readable and has other concerns. It introduces a new It also repeats itself, using the I'd also argue that it's less sophisticated, using lower-level operations instead of a more succinct and reusable approach. Although regex comes with its own pitfalls, it elevates the conversation by re-using well-known (and documented) approaches. Additionally, although the spec is "PEP 503 normalization plus dashes as underscores", it doesn't actually perform PEP 503 normalization, but compiles in the aggregate operation to produce an equivalent output. Compare that with the original implementation, where the code reflected precisely the specified behavior, even though it could have simply subbed to These concerns are mostly just me being pedantic, but I wanted to articulate why I would prefer the prior implementation absent any performance concerns, and why I'd prefer we get a strong rationale for the benefits. Still, I missed my opportunity to get my review in before merged with CPython, so I'm planning to proceed with this change to get the code bases aligned and we can consider reverting later (while keeping the performance and unit tests). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.