-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Why here uses String value -> id format?
shoptimizer/shoptimizer_api/util/gpc_id_to_string_converter.py
Lines 55 to 65 in a9fff3a
| def convert_gpc_id_to_string(self, gpc: Union[str, int]) -> str: | |
| """Looks up and returns the string format of the GPC if it is a number.""" | |
| if isinstance(gpc, int) or gpc.isdigit(): | |
| gpc_string = '' | |
| for key, value in self._gpc_string_to_id_mapping.items(): | |
| if value == int(gpc): | |
| gpc_string = key | |
| break | |
| return gpc_string or '' | |
| else: | |
| return gpc |
If I have a Google Product Categoty = 6797, Python needs to iterate 5437 values to find the String 食品・飲料 > 飲料 > バターミルク , this will be a huge performance issue.
| "食品・飲料 > 飲料 > バターミルク": 6797, |
So, from my opinion, we need to init an id -> String value dictionary, then use o(logn) complexity to get the String
Metadata
Metadata
Assignees
Labels
No labels