Improve performance of name normalization - #533
Conversation
…ance of `importlib.metadata.Prepared.normalized` (#143660) Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
…ce of `importlib.metadata.Prepared.normalized` (#144083) Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
|
Running timeit directly reveals some run time: Aah - so 231 nsec is smaller than the precision of Python's timespan, which only handles microseconds. |
|
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? |
|
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. |
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. |
…termediate implementations. Reference the rationale.

Backport of changes from python/cpython#143658