From 0054cb2c440d405e54b3bdae6ce607495bedbb56 Mon Sep 17 00:00:00 2001 From: Ben West Date: Wed, 20 Oct 2021 19:26:00 -0400 Subject: [PATCH] Replace uuid4 with equivalent faster alternative --- branca/element.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/branca/element.py b/branca/element.py index b624f1b..36a661c 100644 --- a/branca/element.py +++ b/branca/element.py @@ -12,7 +12,8 @@ import warnings from collections import OrderedDict from urllib.request import urlopen -from uuid import uuid4 +from binascii import hexlify +from os import urandom from jinja2 import Environment, PackageLoader, Template @@ -50,7 +51,7 @@ class Element(object): def __init__(self, template=None, template_name=None): self._name = 'Element' - self._id = uuid4().hex + self._id = hexlify(urandom(16)).decode() self._env = ENV self._children = OrderedDict() self._parent = None