| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Could you add the other optimisations as separate commits? |
Sorry, something went wrong.
|
The difference between 27.2 and 26.3 ns is too small and can be the result of unrelated factors. I get a nanosecond variation when run the same command several times. |
Sorry, something went wrong.
Yes, so I'm curious about the other two mentioned optimisations that are not (yet) part of this PR. Perhaps they have a greater impact. |
Sorry, something went wrong.
I created a PR with the other approach: #117782. |
Sorry, something went wrong.
|
Closing this in favor of the alternate PR. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
We apply two optimizations in tailmatch (which is used in both str.startswith and str.endswith).
Notes:
Two possible optimizations not included in this PR:
int first_character_equal = PyUnicode_READ(kind_self, data_self, offset) == PyUnicode_READ(kind_sub, data_sub, 0) if (PyUnicode_GET_LENGTH(substring)==1) { return first_character_equal ; ...This makes the code for the single character case a bit faster, but the code a bit more complex.
Benchmark (on top of #117466): python -m timeit -s "s = 'abcdef'" "s.startswith('a')"