> ...
> value = name.translate(_canonicalize_table)
> while "--" in value:
> value = value.replace("--", "-")
translate can be wildly fast compared to some commonly used regexes or replacements.
This loop handles cases like `eggtools._spam` → `eggtools-spam`, which is probably rare (I guess it’s for packages that export namespaced modules, and you probably don’t want to export _private modules; sorry in advance for non-pythonic terminology). Having more than two separator characters in a row is even more unusual.