| ▲ | djoldman 5 hours ago | |||||||
> _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. | ||||||||
| ▲ | est 3 hours ago | parent | next [-] | |||||||
I am curious, why not .lower().translate('_.', '--') | ||||||||
| ||||||||
| ▲ | teaearlgraycold 4 hours ago | parent | prev [-] | |||||||
I would expect however that a regex replacement would be much faster than your N^2 while loop. | ||||||||
| ||||||||