From a2f68d64100af8018d4ce6123c55896281550dff Mon Sep 17 00:00:00 2001 From: akalankag Date: Tue, 4 Oct 2022 11:40:08 -0600 Subject: [PATCH] dict comprehension is faster than invoking dict constructor --- notebooks/shared/jinja2/lexer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebooks/shared/jinja2/lexer.py b/notebooks/shared/jinja2/lexer.py index 6fd135dd..e4368b39 100644 --- a/notebooks/shared/jinja2/lexer.py +++ b/notebooks/shared/jinja2/lexer.py @@ -136,7 +136,7 @@ ';': TOKEN_SEMICOLON } -reverse_operators = dict([(v, k) for k, v in iteritems(operators)]) +reverse_operators = {v: k for k, v in iteritems(operators)} assert len(operators) == len(reverse_operators), 'operators dropped' operator_re = re.compile('(%s)' % '|'.join(re.escape(x) for x in sorted(operators, key=lambda x: -len(x))))