Skip to content

Commit 0e5f675

Browse files
authored
Merge pull request #49 from IABTechLab/mkc-UID2-3745-email-parsing
Extract EmailParsingState from function
2 parents 41fe441 + 2a9a234 commit 0e5f675

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

uid2_client/input_util.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,22 @@ def is_phone_number_normalized(phone_number):
2222
return min_phone_number_digits <= total_digits <= max_phone_number_digits
2323

2424

25+
# Accessing an enum member is ~3x slower than accessing a non-enum member in Python 3.11.
26+
# This was improved in Python 3.12 but there's still a performance overhead (~44% slower).
27+
# That's why this class isn't an enum.
28+
# https://github.com/python/cpython/issues/93910#issuecomment-1165503032
29+
class EmailParsingState:
30+
Starting = 1
31+
Pre = 2
32+
SubDomain = 3
33+
34+
2535
def normalize_email_string(email):
2636
pre_sb = []
2737
pre_sb_specialized = []
2838
sb = []
2939
ws_buffer = []
3040

31-
class EmailParsingState:
32-
Starting = 1
33-
Pre = 2
34-
SubDomain = 3
35-
3641
parsing_state = EmailParsingState.Starting
3742

3843
in_extension = False

0 commit comments

Comments
 (0)