Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
diff pygments_lexer_pseudocode2/utils.py @ 85:ae5e741d2a9b
Optimize op_explicit_tokentype(): use a pref-computed reversed pygments.token.STANDARD_TYPES
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 30 Apr 2026 19:56:39 +0200 |
| parents | |
| children | 298841bc4dee |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pygments_lexer_pseudocode2/utils.py Thu Apr 30 19:56:39 2026 +0200 @@ -0,0 +1,21 @@ +# -*- coding: utf-8; -*- +# :- +# SPDX-FileCopyrightText: © 2026 Franz Glasner +# SPDX-License-Identifier: MIT +# :- +r"""Some helper utility functions and data. + +""" + +__all__ = ["REVERSED_STANDARD_TYPES"] + + +import pygments.token + + +REVERSED_STANDARD_TYPES = {} + +# Side-effect on import +for _toktype, _cssstyle in pygments.token.STANDARD_TYPES.items(): + REVERSED_STANDARD_TYPES[_cssstyle] = _toktype +del _toktype, _cssstyle
