| ▲ | How we made Python's packaging library 3x faster(iscinumpy.dev) | |||||||||||||||||||||||||||||||
| 46 points by rbanffy 4 days ago | 6 comments | ||||||||||||||||||||||||||||||||
| ▲ | djoldman 3 hours ago | parent | next [-] | |||||||||||||||||||||||||||||||
> _canonicalize_table = str.maketrans( "ABCDEFGHIJKLMNOPQRSTUVWXYZ_.", "abcdefghijklmnopqrstuvwxyz--", ) > ... > value = name.translate(_canonicalize_table) > while "--" in value: > value = value.replace("--", "-") translate can be wildly fast compared to some commonly used regexes or replacements. | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
| ▲ | zahlman 3 days ago | parent | prev [-] | |||||||||||||||||||||||||||||||
Previously: https://news.ycombinator.com/item?id=46557542 | ||||||||||||||||||||||||||||||||