Skip to content

Commit 1058ee0

Browse files
committed
fix: convert to singleton
1 parent 6f8dba5 commit 1058ee0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

json2xml/dicttoxml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# Set up logging
1515
LOG = logging.getLogger("dicttoxml")
1616

17+
_RANDOM = SystemRandom()
1718

1819
def make_id(element: str, start: int = 100000, end: int = 999999) -> str:
1920
"""
@@ -27,8 +28,7 @@ def make_id(element: str, start: int = 100000, end: int = 999999) -> str:
2728
Returns:
2829
str: The generated ID.
2930
"""
30-
safe_random = SystemRandom()
31-
return f"{element}_{safe_random.randint(start, end)}"
31+
return f"{element}_{_RANDOM.randint(start, end)}"
3232

3333

3434
def get_unique_id(element: str) -> str:

0 commit comments

Comments
 (0)