File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -910,14 +910,6 @@ def search(self, prepared: Prepared):
910910 return itertools .chain (infos , eggs )
911911
912912
913- # Translation table for Prepared.normalize: lowercase and
914- # replace "-" (hyphen) and "." (dot) with "_" (underscore).
915- _normalize_table = str .maketrans (
916- "ABCDEFGHIJKLMNOPQRSTUVWXYZ-." ,
917- "abcdefghijklmnopqrstuvwxyz__" ,
918- )
919-
920-
921913class Prepared :
922914 """
923915 A prepared search query for metadata on a possibly-named package.
@@ -953,9 +945,8 @@ def normalize(name):
953945 """
954946 PEP 503 normalization plus dashes as underscores.
955947 """
956- # Emulates ``re.sub(r"[-_.]+", "-", name).lower()`` from PEP 503
957- # About 3x faster, safe since packages only support alphanumeric characters
958- value = name .translate (_normalize_table )
948+ # Much faster than re.sub, and even faster than str.translate
949+ value = name .lower ().replace ("-" , "_" ).replace ("." , "_" )
959950 # Condense repeats (faster than regex)
960951 while "__" in value :
961952 value = value .replace ("__" , "_" )
You can’t perform that action at this time.
0 commit comments