google / google/shoptimizer

[Optimization] Use O(logn) complexity to get the Google Product Category String

Open
#19 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
48
Forks
27
PR merge metrics
No merged PRs in 30d

Description

Why here uses String value -> id format?
https://github.com/google/shoptimizer/blob/a9fff3ac203e39480dff7585fa37b999fbe7470e/shoptimizer_api/util/gpc_id_to_string_converter.py#L55-L65

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.
https://github.com/google/shoptimizer/blob/a9fff3ac203e39480dff7585fa37b999fbe7470e/shoptimizer_api/config/gpc_string_to_id_mapping_ja.json#L5438

So, from my opinion, we need to init an id -> String value dictionary, then use o(logn) complexity to get the String

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.